php-auto-sync-time

时间:17-04-19 栏目:网站开发 作者:admin 评论:0 点击: 620 次

windows2003服务器上用到的时间同步小脚本

 

time.php

<?php
date_default_timezone_set("PRC");

$url ='http://www.beijing-time.org/time15.asp';
$c = file_get_contents($url);
$cs=explode(';',$c);
foreach($cs as $k=>$v){
$tmp = explode('=',$v);
if(!empty($tmp[1])) $cs[$k]=$tmp[1];
}
$time = $cs[1].'-'.$cs[2].'-'.$cs[3].' '.$cs[5].':'.$cs[6].':'.$cs[7];

$time = strtotime($time)*1000;

if($time ){
$date = date('Y-m-d H:i:s',$time/1000);
$time = date('H:i:s',$time/1000);
//echo $time;
echo $date;
//echo $time;
exec("date $date");
exec("time $time");
}else{
echo 'Error';
}
?>

time.bat

@echo off
echo current time is:
time /t
echo.
php time.php

ping 127.0.0.1 -n 60 >nul
echo.
%0

声明: 本文由( admin )原创编译,转载请保留链接: php-auto-sync-time

php-auto-sync-time:等您坐沙发呢!

发表评论


------====== 本站公告 ======------
联系信息:
lxq73061#qq.com qq:583964941
支付宝:https://me.alipay.com/lxq73061
相关插件程序等信息均会在站内发布,敬请关注。

读者排行