当前位置:网站首页>JS how to convert seconds into hours, minutes and seconds display
JS how to convert seconds into hours, minutes and seconds display
2022-07-04 05:42:00 【_ Virgo programmer's daily life】
When we count down, the back end often returns *** second , You need the front-end to display itself on the page in hours, minutes and seconds . How to convert ?
// Written in mouned in :
let time = this.secTotime(61);
console.log(" Convert to minutes and seconds yes ",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
},
边栏推荐
猜你喜欢
[MySQL practice of massive data with high concurrency, high performance and high availability -8] - transaction isolation mechanism of InnoDB
2022 R2 mobile pressure vessel filling retraining question bank and answers
[Excel] 数据透视图
BeanFactoryPostProcessor 与 BeanPostProcessor 相关子类概述
Solar insect killing system based on single chip microcomputer
Topological sorting and graphical display of critical path
Introduction to AMBA
Etcd database source code analysis - initialization overview
What is MQ?
transformer坑了多少算力
随机推荐
Wechat applet +php realizes authorized login
transformer坑了多少算力
BUU-Real-[PHP]XXE
Viewing and using binary log of MySQL
Halcon image calibration enables subsequent image processing to become the same as the template image
配置交叉编译工具链和环境变量
fastjson
冲击继电器JC-7/11/DC110V
Enterprise level log analysis system elk (if things backfire, there must be other arrangements)
[high concurrency, high performance and high availability of massive data MySQL practice-7] - memory data drop disk
Leetcode 184 Employees with the highest wages in the Department (July 3, 2022)
如何获取el-tree中所有节点的父节点
Build an Internet of things infrared temperature measuring punch in machine with esp32 / rush to work after the Spring Festival? Baa, no matter how hard you work, you must take your temperature first
(4) Canal multi instance use
[interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre
如何判断数组中是否含有某个元素
Principle and practice of common defects in RSA encryption application
Solar insect killing system based on single chip microcomputer
Actual cases and optimization solutions of cloud native architecture
c语言经典指针和数组笔试题解析