Author - Marcus S. Xenakis 9/11/99
marcus@xenakis.net
Amateur Radio Callsign - WA2DCI
This script is distributed as-is under GNU public
license. Please leave the credit line in the script.
This script obtains the current Universal Time from
the National Institute of Standards and Technology
of the United States of America.
It can be used as ssi tag for an HTML page
<!--exec cgi="utcnist.cgi"-->
or and an include in another PHP script.
You many need to modify the first line for the path
to your PHP interpreter.
NOTICE: The time signals are corrected for network
propagation delays. You should select the time
server with the shortest network path to you.
Then modify the $site varible for that site.
For complete information on time servers see:
http://www.bldrdoc.gov/timefreq/service/nts.htm
*/
$site = "time-a.nist.gov";
$fp = fsockopen($site,13,&$errno,&$errstr);
if (!$fp) {
echo "Error Connecting to NIST\n";
} else {
$line = fread($fp,64);
fclose($fp);
$array = explode(" ",$line);
if ($array[5] == 4) {
echo "Error in NIST Time Signal\n";
} else {
echo substr($array[1],3);echo "-";
echo substr($array[1],0,2);echo "";
echo "$array[2]";
echo "UTC(NIST)\n";
}
}
?>