静态网页如何实现与系统同步时间

来源:百度知道 编辑:UC知道 时间:2024/05/24 07:17:10
代码怎么写?

要动态显示当前时间,只有用客户端时间.用JAVASCRIPT脚本比较好.这里有一个完整的用JavaScript显示时钟的例子,希望对你有所帮助:

<SCRIPT language=JavaScript>
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = " " + ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds <