[email protected] wrote:
> I am looking for some way to poll a synced stratum 2 NTP server
> over an http connection every hour or so to obtain the
> current time in milliseconds.
JFGI ?
---------|---------|---------|---------|---------|---------|
Use ntpd to sync your PC with your NTP server, or the NTP pool then:
<HTML>
<HEAD>
<TITLE> Time </TITLE>
<META NAME="Keywords" CONTENT="Date,Time">
<META NAME="Description" CONTENT="Date,Time">
</HEAD>
<BODY>
<script>
var d=new Date();
var n = d.getUTCMilliseconds();
var UTCFullYear = d.getUTCFullYear();
var UTCMonth = d.getUTCMonth();
var UTCDate = d.getUTCDate();
var UTCDay = d.getUTCDay();
var UTCHours = d.getUTCHours();
var UTCMinutes = d.getUTCMinutes();
var UTCSeconds = d.getUTCSeconds();
var UTCMilliseconds = d.getUTCMilliseconds();
document.write(UTCFullYear,"-",UTCMonth,"-",UTCDate,"
",UTCHours,":",UTCMinutes,":",UTCSeconds,".",UTCMilliseconds);
</script>
</BODY>
</HTML>
---------|---------|---------|---------|---------|---------|
Use ntpd to sync your web server(s) with your NTP server, or the NTP pool then:
Add the feature to web pages on your own web server(s)?
PHP, PERL, Java, ... other CGIs, SSI ?
... whatever other language you may be developing in
<http://currentmillis.com/>
e.g. PHP
<php.net/manual/en/datetime.construct.php>
<php.net/microtime>
<devmanuals.com/tutorials/php/date/php-date-microseconds.html>
<stackoverflow.com/questions/17909871/getting-date-format-m-d-y-his-u-from-milliseconds>
---------|---------|---------|
$t = microtime(true);
$micro = sprintf("%06d",($t - floor($t)) * 1000000);
$d = new DateTime( date('Y-m-d H:i:s.'.$micro,$t) );
print $d->format("Y-m-d H:i:s.u");
---------|---------|---------|
function timeAndMilliseconds()
{
$m = explode(' ',microtime());
return array($m[1], (int)round($m[0]*1000,3));
}
list($totalSeconds, $extraMilliseconds) = timeAndMilliseconds();
echo date("d-m-Y H:i:s", $totalSeconds) . ".$extraMilliseconds\n";
echo date("d-m-Y H:i:s") . "\n";
--
E-Mail Sent to this address <[email protected]>
will be added to the BlackLists.
_______________________________________________
questions mailing list
[email protected]
http://lists.ntp.org/listinfo/questions