1703839817转化为时分秒
时间: 2024-06-14 18:05:20 浏览: 52
js 毫秒转天时分秒的实例
5星 · 资源好评率100%
以下是将时间戳转换为时分秒的方法:
```javascript
function toHHmmss(timestamp) {
var time;
var hours = parseInt((timestamp % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = parseInt((timestamp % (1000 * 60 * 60)) / (1000 * 60));
var seconds = (timestamp % (1000 * 60)) / 1000;
time = (hours < 10 ? ('0' + hours) : hours) + ':' + (minutes < 10 ? ('0' + minutes) : minutes) + ':' + (seconds < 10 ? ('0' + seconds) : seconds);
return time;
}
var timestamp = 1703839817;
var time = toHHmmss(timestamp);
console.log(time); // 输出:472177:43:37
```
阅读全文