码迷,mamicode.com
首页 > 其他好文 > 详细

时间戳转时分秒

时间:2021-01-11 11:07:41      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:second   hmm   ons   bsp   时间戳   mss   time   log   需要   

 

只需要        toHHmmss(时间戳)即可

function toHHmmss (data) {
var time;
var hours = parseInt((data % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = parseInt((data % (1000 * 60 * 60)) / (1000 * 60));
var seconds = (data % (1000 * 60)) / 1000;
time = (hours < 10 ? (‘0‘ + hours) : hours) + ‘:‘ + (minutes < 10 ? (‘0‘ + minutes) : minutes) + ‘:‘ + (seconds < 10 ? (‘0‘ + seconds) : seconds);
return time;
console.log(time)
}

时间戳转时分秒

标签:second   hmm   ons   bsp   时间戳   mss   time   log   需要   

原文地址:https://www.cnblogs.com/xxshen/p/14251507.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!