代码如下:
<?php /** * 获取服务器时间 动态显示 * Edit www.jb200.com */ header("content-type:text/html;charset=utf-8"); date_default_timezone_set("PRC");//定义时区 echo '<div id="time"></div> <script type="text/javascript"> function $(o){ return document.getElementById(o); } var ts='.(round(microtime(true)*1000)) . '; function getTime(){ var t=new Date(ts); with(t){ var _time="现在是:"+getFullYear()+"-" + (getMonth()+1)+"-"+getDate()+" " + (getHours()<10 ? "0" :"") + getHours() + ":" + (getMinutes()<10 ? "0" :"") + getMinutes() + ":" + (getSeconds()<10 ? "0" :"") + getSeconds(); } $("time").innerHTML=_time; setTimeout("getTime()",1000); ts+=1000; } getTime(); </script>'; ?>