PHP获取远程网站的服务器时间
<?php
function get_time($server){
$data = "HEAD / HTTP/1.1\r\n";
$data .= "Host: $server\r\n";
$data .= "Connection: Close\r\n\r\n";
$fp = fsockopen($server, 80);
fputs($fp, $data);
$resp = '';
while ($fp && !feof($fp))
$resp .= fread($fp, 1024);
preg_match('/^Date: (.*)$/mi',$resp,$matches);
return strtotime($matches[1]);
}
?>
<?php
echo date('Y-m-d H:i:s',get_time("127.0.0.1"));
?>
http://www.codefans.net/articles/1220.shtml