当前位置:网站首页>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
},
边栏推荐
- flink1.13 sql基础语法(二)join操作
- flink1.13 sql基础语法(一)DDL、DML
- Unity is connected to the weather system
- BUU-Crypto-[GUET-CTF2019]BabyRSA
- [matlab] general function of communication signal modulation bandpass filter
- 19. Framebuffer application programming
- [matlab] general function of communication signal modulation - generation of narrow-band Gaussian white noise
- The data mark is a piece of fat meat, and it is not only China Manfu technology that focuses on this meat
- Letter meaning and parameter abbreviation of optical module Daquan
- [interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre
猜你喜欢
Overview of relevant subclasses of beanfactorypostprocessor and beanpostprocessor
Simulink and Arduino serial port communication
[QT] timer
VB. Net GIF (making and disassembling - optimizing code, class library - 5)
1480. Dynamic sum of one-dimensional array
Evolution of system architecture: differences and connections between SOA and microservice architecture
Upper computer software development - log information is stored in the database based on log4net
ETCD数据库源码分析——初始化总览
How to use postman to realize simple interface Association [add, delete, modify and query]
如何使用postman实现简单的接口关联【增删改查】
随机推荐
TCP state transition diagram
空洞卷积、可变形卷积、可变形ROI Pooling
Notepad++ -- display related configurations
Integer type of C language
left_and_right_net可解释性设计
IP时代来临,电竞酒店如何借好游戏的“东风”?
Excel 比较日器
June 2022 summary
1480. 一维数组的动态和
What is MQ?
KMP match string
(4) Canal multi instance use
Wechat applet +php realizes authorized login
ping端口神器psping
The data mark is a piece of fat meat, and it is not only China Manfu technology that focuses on this meat
Google Chrome browser will support the function of selecting text translation
C language simple student management system (including source code)
Canoe panel learning video
Descriptive analysis of data distribution characteristics (data exploration)
How to use postman to realize simple interface Association [add, delete, modify and query]