Thursday, 4 June 2015

PHP: Atomic time

<?php
$fp = fsockopen("time-a.nist.gov", 37);
if ($fp) {
fputs($fp, "\n");
$timevalue = fread($fp, 49);
fclose($fp);
}

$atomic_time = (abs(hexdec('7fffffff') - hexdec(bin2hex($timevalue)) - hexdec('7fffffff')) - 2208988800);
echo $atomic_time;
?>

This returns the time in the form of a timestamp

0 comments:

Post a Comment