当前位置:网站首页>js如何将秒转换成时分秒显示
js如何将秒转换成时分秒显示
2022-07-04 05:29:00 【_处女座程序员的日常】
我们在做倒计时时后端经常给我们返回***秒,需要前端自己在页面上显示成时分秒的样子。如何转换?
// 写在mouned中:
let time = this.secTotime(61);
console.log("转换为时分秒是",time);
// methods:
secTotime(s) {
var t = '';
if(s > -1){
var hour = Math.floor(s/3600)
var min = Math.floor(s/60) % 60
var sec = s % 60
if(hour < 10) {
t = '0'+ hour + ":"
} else {
t = hour + ":"
}
if(min < 10){
t += "0"
}
t += min + ":"
if(sec < 10){
t += "0"
}
t += sec.toFixed(0)
}
return t
},

边栏推荐
- Use of hutool Pinyin tool
- [paper summary] zero shot semantic segmentation
- [QT] create mycombobox click event
- Introduction to AMBA
- XII Golang others
- SQL performance optimization skills
- [QT] timer
- Just do it with your hands 7 - * project construction details 2 - hook configuration
- Penetration tool - sqlmap
- 十二. golang其他
猜你喜欢

企业级日志分析系统ELK(如果事与愿违那一定另有安排)

Penetration tool - sqlmap

拓扑排序和关键路径的图形化显示

Principle and practice of common defects in RSA encryption application

谷歌 Chrome 浏览器将支持选取文字翻译功能
![BUU-Crypto-[GUET-CTF2019]BabyRSA](/img/87/157066155e8d3a93e30a68eaf1781b.jpg)
BUU-Crypto-[GUET-CTF2019]BabyRSA

【兴趣阅读】Adversarial Filtering Modeling on Long-term User Behavior Sequences for Click-Through Rate Pre

【QT】制作MyComboBox点击事件

ping端口神器psping

1480. Dynamic sum of one-dimensional array
随机推荐
[matlab] general function of communication signal modulation - generation of narrow-band Gaussian white noise
TCP state transition diagram
fastjson
Viewing and using binary log of MySQL
Letter meaning and parameter abbreviation of optical module Daquan
补某视频网站的js,进行视频解密
Zzulioj:1201: mode problem
Descriptive analysis of data distribution characteristics (data exploration)
Input displays the currently selected picture
如何使用postman实现简单的接口关联【增删改查】
The data mark is a piece of fat meat, and it is not only China Manfu technology that focuses on this meat
Introduction To AMBA 简单理解
1480. 一维数组的动态和
Appearance of LabVIEW error dialog box
724. 寻找数组的中心下标
transformer坑了多少算力
724. Find the central subscript of the array
Use of hutool Pinyin tool
JS string splicing
Excel 比较日器