首页 > Web开发 > 详细

js网页底部运行时间代码

时间:2019-04-09 21:33:14      阅读:171      评论:0      收藏:0      [点我收藏+]

<center>主人,我勉强战斗了<br><span id="htmer_time" style="color: green;"></span>
<script>
function secondToDate(second) {
if (!second) {
return 0;
}
var time = new Array(0, 0, 0, 0, 0);
if (second >= 365 * 24 * 3600) {
time[0] = parseInt(second / (365 * 24 * 3600));
second %= 365 * 24 * 3600;
}
if (second >= 24 * 3600) {
time[1] = parseInt(second / (24 * 3600));
second %= 24 * 3600;
}
if (second >= 3600) {
time[2] = parseInt(second / 3600);
second %= 3600;
}
if (second >= 60) {
time[3] = parseInt(second / 60);
second %= 60;
}
if (second > 0) {
time[4] = second;
}
return time;
}</script><script type="text/javascript" language="javascript">
function setTime() {
var create_time = Math.round(new Date(Date.UTC(2019, 01, 00, 0, 0, 0)).getTime() / 1000);
var timestamp = Math.round((new Date().getTime() + 8 * 60 * 60 * 1000) / 1000);
currentTime = secondToDate((timestamp - create_time));
currentTimeHtml = currentTime[0] + ‘年‘ + currentTime[1] + ‘天‘
+ currentTime[2] + ‘时‘ + currentTime[3] + ‘分‘ + currentTime[4]
+ ‘秒‘;
document.getElementById("htmer_time").innerHTML = currentTimeHtml;
} setInterval(setTime, 1000);</script>
</center>

js网页底部运行时间代码

原文:https://www.cnblogs.com/greenlili/p/10679761.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!