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

边栏推荐
- 2022危险化学品经营单位安全管理人员上岗证题库及答案
- Topological sorting and graphical display of critical path
- 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
- Canoe panel learning video
- The data mark is a piece of fat meat, and it is not only China Manfu technology that focuses on this meat
- 19. Framebuffer application programming
- Trie number dictionary tree
- LM小型可编程控制器软件(基于CoDeSys)笔记二十一:错误3703
- 2022G2电站锅炉司炉特种作业证考试题库及答案
- Risc-v-qemu-virt in FreeRTOS_ Lock mechanism analysis of GCC
猜你喜欢

VB. Net GIF (making and disassembling - optimizing code, class library - 5)

LM small programmable controller software (based on CoDeSys) note 22: error 4268/4052

2022年R2移动式压力容器充装复训题库及答案

VB.net GIF(制作、拆解——优化代码,类库——5)
![[QT] create mycombobox click event](/img/5a/ed17567a71f6737891fc7a8273df0a.png)
[QT] create mycombobox click event

Programming example of stm32f1 and stm32subeide -74hc595 drives 4-bit 7-segment nixie tube

Accidentally deleted the data file of Clickhouse, can it be restored?

C # character similarity comparison general class

What is MQ?

Character types of C language
随机推荐
Enterprise level log analysis system elk (if things backfire, there must be other arrangements)
724. 寻找数组的中心下标
How to use postman to realize simple interface Association [add, delete, modify and query]
[paper summary] zero shot semantic segmentation
Just do it with your hands 7 - * project construction details 2 - hook configuration
Supplement the JS of a video website to decrypt the video
FreeRTOS 中 RISC-V-Qemu-virt_GCC 的 锁机制 分析
Flink1.13 basic SQL syntax (II) join operation
VB. Net calls ffmpeg to simply process video (class Library-6)
Viewing and using binary log of MySQL
2022年T电梯修理操作证考试题库及模拟考试
Principle and practice of common defects in RSA encryption application
June 2022 summary
Topological sorting and graphical display of critical path
2022g2 power station boiler stoker special operation certificate examination question bank and answers
Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
BUU-Reverse-easyre
Notepad++--显示相关的配置
Flask
XII Golang others