mixed findtimediff([string server [, int port [, int timeout]]]) -- Find the number of seconds your local clock is wrong
<?php |
This will output:
Your local time is -277 seconds off |
Published under the terms of the BSD License
<?php
function findtimediff($server = "time-a.nist.gov", $port = 13, $timeout = 10) {
$sp = @fsockopen($server, $port, $errno, $errstr, $timeout);
if (!$sp) {
return false;
}
else {
list($mjd, $date, $time, $tt, $l, $h, $msADV, $utcnist, $otm) = explode(" ", trim(fread($sp, 256)));
$remote = strtotime($date." ".$time) + date('Z');
fclose($sp);
}
$local = time();
return $remote - $local;
}
?>
Last updated: Sat Jun 14 20:02:45 CEST 2008