日期:2014-05-16 浏览次数:20371 次
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); }