当前位置:网站首页>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
},
边栏推荐
- 1480. 一维数组的动态和
- KMP match string
- BUU-Crypto-[GXYCTF2019]CheckIn
- Viewing and using binary log of MySQL
- Solar insect killing system based on single chip microcomputer
- C language simple student management system (including source code)
- SQL injection - injection based on MSSQL (SQL Server)
- BUU-Crypto-[GUET-CTF2019]BabyRSA
- Programmers don't talk about morality, and use multithreading for Heisi's girlfriend
- Flask
猜你喜欢
LM小型可编程控制器软件(基于CoDeSys)笔记二十一:错误3703
(4) Canal multi instance use
数据标注是一块肥肉,盯上这块肉的不止中国丨曼孚科技
HMS v1.0 appointment.php editid参数 SQL注入漏洞(CVE-2022-25491)
Upper computer software development - log information is stored in the database based on log4net
Simulated small root pile
基于单片机的太阳能杀虫系统
Flask
[paper summary] zero shot semantic segmentation
Arc135 C (the proof is not very clear)
随机推荐
[matlab] general function of communication signal modulation Fourier transform
Risc-v-qemu-virt in FreeRTOS_ Lock mechanism analysis of GCC
LabVIEW错误对话框的出现
Thinkphp6.0 middleware with limited access frequency think throttle
Accidentally deleted the data file of Clickhouse, can it be restored?
RSA加密应用常见缺陷的原理与实践
What is MQ?
C # character similarity comparison general class
BUU-Reverse-easyre
十二. golang其他
fastjson
JS string splicing enhancement
Graduation design of small programs -- small programs of food and recipes
Excel comparator
【兴趣阅读】Adversarial Filtering Modeling on Long-term User Behavior Sequences for Click-Through Rate Pre
BUU-Crypto-[HDCTF2019]basic rsa
Simulink and Arduino serial port communication
VB.net 简单的处理图片,黑白(类库——7)
Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
[wechat applet] template and configuration (wxml, wxss, global and page configuration, network data request)