当前位置:网站首页>js将秒转换成“2h30min50s”的格式
js将秒转换成“2h30min50s”的格式
2022-06-29 18:10:00 【bidepanm】
formatSeconds(value) {
let theTime = parseInt(value);// 需要转换的时间秒
let theTime1 = 0;// 分
let theTime2 = 0;// 小时
let theTime3 = 0;// 天
if(theTime > 60) {
theTime1 = parseInt(theTime/60);
theTime = parseInt(theTime%60);
if(theTime1 > 60) {
theTime2 = parseInt(theTime1/60);
theTime1 = parseInt(theTime1%60);
if(theTime2 > 24){
//大于24小时
theTime3 = parseInt(theTime2/24);
theTime2 = parseInt(theTime2%24);
}
}
}
let result = '';
if(theTime > 0){
result = ""+parseInt(theTime)+"s";
}
if(theTime1 > 0) {
result = ""+parseInt(theTime1)+"min"+result;
}
if(theTime2 > 0) {
result = ""+parseInt(theTime2)+"h"+result;
}
if(theTime3 > 0) {
result = ""+parseInt(theTime3)+"day"+result;
}
return result;
}
边栏推荐
- Adobe Premiere基础-编辑素材文件常规操作(脱机文件,替换素材,素材标签和编组,素材启用,便捷调节不透明度,项目打包)(十七)
- 《安富莱嵌入式周报》第271期:2022.06.20--2022.06.26
- Sd6.24 summary of intensive training
- 【TcaplusDB知识库】TcaplusDB单据受理-事务执行介绍
- Elegant writing controller (parameter verification + unified exception handling)
- Usage of BeanUtils property replication
- My first experience of remote office | community essay solicitation
- Sword finger offer 34 Path DFS method for binary tree neutralization
- Chapter 02_ MySQL data directory
- Travel card "star picking" hot search first! Stimulate the search volume of tourism products to rise
猜你喜欢

Error building sqlsession problem

Adobe Premiere Basics - common video effects (corner positioning, mosaic, blur, sharpen, handwriting tools, effect control hierarchy) (16)

MySQL -connector/j driver download

山东大学项目实训(七)添加导航栏选择城市

Adobe Premiere Foundation - réglage du son (correction du volume, réduction du bruit, tonalité téléphonique, changement de hauteur, égaliseur de paramètres) (XVIII)
MySql存储过程循环的使用分析详解

AMAZING PANDAVERSE:META”无国界,来2.0新征程激活时髦属性

mysql -connector/j驱动下载

Fluent's MSH grid learning

Adobe Premiere foundation - batch material import sequence - variable speed and rewind (recall) - continuous action shot switching - subtitle requirements (13)
随机推荐
markdown知识轻轻来袭
Shell基本语法--流程控制
Adobe Premiere foundation - cool text flash (14)
Precondition end of script headers or end of script output before headers
保持jupyter notebook在终端关闭时的连接方法
Longest XOR path (dfs+01trie)
Anaconda安装并配置jupyter notebook远程
Proxmox VE Install 7.2
Sd6.25 summary of intensive training
Lodash deep copy usage
shell教程之循环语句for,while,until用法
[tcapulusdb knowledge base] tcapulusdb doc acceptance - Introduction to creating game area
Data-* attribute usage
Request header field XXXX is not allowed by access control allow headers in preflight response
Goldfish rhca memoirs: do447 build advanced job workflow -- create job template survey to set work variables
3H proficient in opencv (VII) - color detection
Configure the local domain name through the hosts file
Detailed analysis on the use of MySQL stored procedure loop
报错Failed to allocate graph: MYRIAD device is not opened.
山东大学项目实训(六)点击事件展示折线图