当前位置:网站首页>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
},

边栏推荐
- 如何使用postman实现简单的接口关联【增删改查】
- 空洞卷积、可变形卷积、可变形ROI Pooling
- VB. Net simple processing pictures, black and white (class library - 7)
- tutle时钟改进版
- BUU-Pwn-test_ your_ nc
- RSA加密应用常见缺陷的原理与实践
- Introduction To AMBA 简单理解
- Programming example of stm32f1 and stm32subeide -74hc595 drives 4-bit 7-segment nixie tube
- Use of hutool Pinyin tool
- Yyds dry goods inventory TCP & UDP
猜你喜欢

Ping port artifact psping

VB.net 简单的处理图片,黑白(类库——7)

Online shrimp music will be closed in January next year. Netizens call No

ansys命令

One click filtering to select Baidu online disk files

What is MQ?

光模塊字母含義及參數簡稱大全

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

Overview of relevant subclasses of beanfactorypostprocessor and beanpostprocessor

What are the reasons for the frequent high CPU of ECS?
随机推荐
BUU-Reverse-easyre
Viewing and using binary log of MySQL
2022G2电站锅炉司炉特种作业证考试题库及答案
[QT] create mycombobox click event
Introduction to AMBA
Yyds dry goods inventory TCP & UDP
ping端口神器psping
Letter meaning and parameter abbreviation of optical module Daquan
BUU-Crypto-[GXYCTF2019]CheckIn
Remote desktop client RDP
BUU-Crypto-Cipher
c语言经典指针和数组笔试题解析
[matlab] communication signal modulation general function interpolation function
Introduction To AMBA 简单理解
left_and_right_net可解释性设计
Programmers don't talk about morality, and use multithreading for Heisi's girlfriend
Topological sorting and graphical display of critical path
Unity2D--人物移动并转身
Enterprise level log analysis system elk (if things backfire, there must be other arrangements)
Appearance of LabVIEW error dialog box