js时间统计

编程入门 行业动态 更新时间:2024-10-17 09:39:48

js<a href=https://www.elefans.com/category/jswz/34/1771441.html style=时间统计"/>

js时间统计

// 时间统计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;}/*此处为初始时间*/function setTime() {var create_time = Math.round(new Date(Date.UTC(2020, 11, 27, 15, 15, 15)).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;}

更多推荐

js时间统计

本文发布于:2024-03-10 05:55:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1727158.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时间   js

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!