首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

js记时

2012-08-02 
js倒计时newDate 参数?Y,m,d,H,i,s月份(0-11)??htmlbodyspan剩余时间:/spanspan iddd /sp

js倒计时

newDate 参数?"Y,m,d,H,i,s"

月份(0-11)?

?

<html><body>                <span>剩余时间:</span>                <span id="dd" ></span>                <span id="hh"></span>                <span id="mm" ></span>                <span id="ss" ></span></body></html>

?

window.addEvent('domready', function() {clock();});function clock(){var differHour = -1;var differMinute = -1;var differSecond = -1;var endTime = new Date(<?php $this->put($endTime);?>);//结束时间var daysms = 24 * 60 * 60 * 1000;var hoursms = 60 * 60 * 1000;var secondms = 60 * 1000;var microsecond = 1000;    var time = new Date();    var hour = time.getHours();    var minute = time.getMinutes();    var second = time.getSeconds();    var timevalue = ""+((hour > 12) ? hour-12:hour);    timevalue +=((minute < 10) ? ":0":":")+minute;    timevalue +=((second < 10) ? ":0":":")+second;    timevalue +=((hour >12 ) ? " PM":" AM");    var convertHour = differHour;    var convertMinute = differMinute;    var convertSecond = differSecond;    var Diffms = endTime.getTime() - time.getTime();    differHour = Math.floor(Diffms / daysms);    Diffms -= differHour * daysms;    differMinute = Math.floor(Diffms / hoursms);    Diffms -= differMinute * hoursms;    differSecond = Math.floor(Diffms / secondms);    Diffms -= differSecond * secondms;    var dSecs = Math.floor(Diffms / microsecond);    if(convertHour != differHour) $("dd").set('text', differHour + '天');    if(convertMinute != differMinute) $("hh").set('text', differMinute + '小时');    if(convertSecond != differSecond) $("mm").set('text', differSecond + '分');    $("ss").set('text', dSecs + '秒');setTimeout("groupClock()",1000);}

热点排行