時計の種類 時計の時刻
原子時計1900/01/01(Mon)09:00:00
サーバ時計2018/10/19(Fri)12:16:28


時計の時刻
<table border>
<?php

function atomic_time($server, $port)
{
    $fp = fsockopen($server, $port);
    if ($fp) {
        fputs($fp, "\n");
        $timevalue = fread($fp, 49);
        fclose($fp);
    }
   $pre = (abs(hexdec('7fffffff') - hexdec(bin2hex($timevalue)) - hexdec('7fffffff')) - 2208988800);
    return $pre;
}

$time = atomic_time("time-a.nist.gov", 37);
$a_time = gmdate("Y/m/d(D)H:i:s", $time+9*3600 );
print "<tr><td>原子時計</td><td>".$a_time . "</td></tr>\n";
$s_time = gmdate("Y/m/d(D)H:i:s", time()+9*3600 );
print "<tr><td>サーバ時計</td><td>".$s_time . "</td></tr>\n";
?>

<script language='JavaScript'>
wa = new Array('sun', 'Mon', 'Tue','Wed','Thu','Fri','Sat');
today = new Date();
yy= today.getYear();
if (yy < 1900) yy += 1900;
mm = today.getMonth()+1;if(mm<10)mm='0'+mm;
dd = today.getDate();if(dd<10)dd='0'+dd;
ww = today.getDay();
hh = today.getHours();if(hh<10)hh='0'+hh;
nn = today.getMinutes();if(nn<10)nn='0'+nn;
ss = today.getSeconds();if(ss<10)ss='0'+ss;
document.write('<tr><td>パソコンの時計</td><td>',yy+'/'+mm+'/'+dd+'('+wa[ww]+')'+hh+':'+nn+':'+ss+'</td></tr>');
</script>
</table>