倒计时

chenyajun  2020-01-29 15:13:56  阅读 2344 次 评论 0 条
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function getTime() {
now = new Date();
y2k = new Date("Jan 1 2030 14:00:00");
days = (y2k - now) / 1000 / 60 / 60 / 24;
daysRound = Math.floor(days);
hours = (y2k - now) / 1000 / 60 / 60 - (24 * daysRound);
hoursRound = Math.floor(hours);
minutes = (y2k - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
minutesRound = Math.floor(minutes);
seconds = (y2k - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
secondsRound = Math.round(seconds);
sec = (secondsRound == 1) ? " second." : " 秒.";
min = (minutesRound == 1) ? " minute" : " 分, ";
hr = (hoursRound == 1) ? " hour" : " 小时, ";
dy = (daysRound == 1)  ? " day" : " 天, "
document.timeForm.input1.value = "剩余时间: " + daysRound  + dy + hoursRound + hr + minutesRound + min + secondsRound + sec;
newtime = window.setTimeout("getTime();", 1000);
}
</script>
</head>
<body onLoad="getTime()" style="font-weight:bold; color:#c00;">
距离 2030年一月一日下午2:00
<form name=timeForm>
<input type=text name=input1 size=70 border-style="none" style="border-bottom: 0px solid; border-left: 0px solid;border-right: 0px solid;border-top: 0px solid;font:12px arial, helvetica,sans-serif; color:#c00; font-weight:bold;">
</form>
</body>
</html>


本文地址:https://chenyajun.net/index.php/post/16.html
版权声明:本文为原创文章,版权归 chenyajun 所有,欢迎分享本文,转载请保留出处!

评论已关闭!