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

边栏推荐
- 2022g2 power station boiler stoker special operation certificate examination question bank and answers
- 2022G2电站锅炉司炉特种作业证考试题库及答案
- Excel 比较日器
- LM小型可编程控制器软件(基于CoDeSys)笔记二十二:错误4268/4052
- Flink1.13 basic SQL syntax (II) join operation
- Arc135 a (time complexity analysis)
- Notepad++ -- display related configurations
- 2022危险化学品经营单位安全管理人员上岗证题库及答案
- Introduction to AMBA
- [QT] create mycombobox click event
猜你喜欢
![[paper summary] zero shot semantic segmentation](/img/78/ee64118d86a7e43ec4d1cb97191fbe.jpg)
[paper summary] zero shot semantic segmentation

拓扑排序和关键路径的图形化显示

Simulink与Arduino串口通信

Introduction To AMBA 简单理解

BeanFactoryPostProcessor 与 BeanPostProcessor 相关子类概述

VB.net GIF(制作、拆解——优化代码,类库——5)

Automated testing selenium foundation -- webdriverapi

Arc135 C (the proof is not very clear)

What is MQ?
![[MySQL practice of massive data with high concurrency, high performance and high availability -8] - transaction isolation mechanism of InnoDB](/img/8e/90d08d22a2d340242be2357f662ea4.jpg)
[MySQL practice of massive data with high concurrency, high performance and high availability -8] - transaction isolation mechanism of InnoDB
随机推荐
JS string splicing enhancement
Programming example of stm32f1 and stm32subeide -74hc595 drives 4-bit 7-segment nixie tube
PostgreSQL has officially surpassed mysql. Is this guy too strong!
C language simple student management system (including source code)
Solar insect killing system based on single chip microcomputer
Yyds dry goods inventory TCP & UDP
[Excel] 数据透视图
How to configure static IP for Kali virtual machine
[paper summary] zero shot semantic segmentation
数据标注是一块肥肉,盯上这块肉的不止中国丨曼孚科技
19. Framebuffer application programming
基于单片机的太阳能杀虫系统
Just do it with your hands 7 - * project construction details 2 - hook configuration
How to clone objects
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
LabVIEW错误对话框的出现
[MySQL practice of massive data with high concurrency, high performance and high availability -8] - transaction isolation mechanism of InnoDB
[QT] timer
[technology development -25]: integration technology of radio and television network, Internet, telecommunication network and power grid
十二. golang其他