我们需要的是纽约时间也就是西五区28日,晚上11点!~[code lang=”js”]
<div style="position:absolute; left:50px; bottom:50px; ">
<script language="JavaScript">
<!–
var DifferenceHour = -1
var DifferenceMinute = -1
var DifferenceSecond = -1
var Tday = new Date("Tue Feb 28 2012 22:59:59 GMT-0500")//我们需要的是纽约时间也就是西五区28日,晚上11点!~
var daysms = 24 * 60 * 60 * 1000
var hoursms = 60 * 60 * 1000
var Secondms = 60 * 1000
var microsecond = 1000
function clock()
{
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")
// document.formnow.now.value = timevalue
var convertHour = DifferenceHour
var convertMinute = DifferenceMinute
var convertSecond = DifferenceSecond
var Diffms = Tday.getTime() – time.getTime()
DifferenceHour = Math.floor(Diffms / daysms)
Diffms -= DifferenceHour * daysms
DifferenceMinute = Math.floor(Diffms / hoursms)
Diffms -= DifferenceMinute * hoursms
DifferenceSecond = Math.floor(Diffms / Secondms)
Diffms -= DifferenceSecond * Secondms
var dSecs = Math.floor(Diffms / microsecond)
if(convertHour != DifferenceHour) document.formnow.dd.value=DifferenceHour
if(convertMinute != DifferenceMinute) document.formnow.hh.value=DifferenceMinute
if(convertSecond != DifferenceSecond) document.formnow.mm.value=DifferenceSecond
document.formnow.ss.value=dSecs
// document.formnow.Tnow.value= DifferenceHour DifferenceMinute + DifferenceSecond + dSecs
setTimeout("clock()",1000)
}
// end hiding –>
</script><form name="formnow">
<input type="text" name="dd" style="width:40px; background:none; border:none;color:#ffa200; font-size:24px; font-weight:bold">
<input type="text" name="hh" style="width:50px; background:none; border:none;color:#ffa200; font-size:24px; font-weight:bold">
<input type="text" name="mm" style="width:40px; background:none; border:none;color:#ffa200; font-size:24px; font-weight:bold">
<input type="text" name="ss" style="width:30px; background:none; border:none;color:#ffa200; font-size:24px; font-weight:bold">
</form>
</div>
[/code]
“js倒计时,不按时区算”的一个回复
评论已关闭。