Forum Moderators: coopster
[edited by: coopster at 7:50 pm (utc) on Oct. 29, 2003]
The far best possibility is to keep your own web server's time accurate, either in sync with NTP (xntpd) or just by a daily update with ntpdate, and then just ask for the time locally:
<?php echo gmdate("Y-m-d H:i.s");?>
Regards,
R.
<?php
$handle = fsockopen("time-b.timefreq.bldrdoc.gov", 13, $errno, $errstr);
if (!$handle) {
print "ERROR: $errno - $errstr<br>\n";
} else {
$daytime = fread($handle, 50);
fclose($handle);
if (preg_match("/\s+\d+-\d+-\d+\s+/", $daytime, $matches)) $date = $matches[0];
if (preg_match("/\s+\d+:\d+:\d+\s+/", $daytime, $matches)) $time = $matches[0];
}
print $daytime.'<br >';
print $date.'<br >';
print $time.'<br >';
?>
Now, while the topic is open...
According to NIST [boulder.nist.gov],
The Network Time Protocol (NTP) is the most commonly used Internet time protocol, and the one that provides the best performance.
Regards,
R.
Someday, in my spare time, I'll dig deeper into SNTP and your Perl code and work on a PHP conversion. In the meantime I'll use the DAYTIME protocol -- when I need it ;)
Thanks again -- coopster