当前位置:网站首页>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;
}
边栏推荐
- shell教程之循环语句for,while,until用法
- 数据分析基础--预测模型
- My first experience of remote office | community essay solicitation
- jdbc_相關代碼
- 通过 hosts文件配置本地域名
- Weibo comments on high-performance and high availability architecture design (module 5 of architecture practice camp)
- Sister Juan takes you to learn database -- 5-day sprint Day1
- Adobe Premiere foundation - cool text flash (14)
- How to use an oak camera as a webcam?
- 2022.6.29-----leetcode. five hundred and thirty-five
猜你喜欢
随机推荐
Application and practice of DDD in domestic hotel transaction -- Theory
Find the maximum XOR value in the sequence given a number (01 Dictionary)
Sister Juan takes you to learn database -- 5-day sprint Day1
山东大学项目实训(八)设计轮播图进入页面
jdbc_ Related codes
JWT login authentication
Image feature computation and representation -- content based image retrieval
Configure the local domain name through the hosts file
6.29模拟赛总结
SD6.22集训总结
Adobe Premiere基础-素材嵌套(制作抖音结尾头像动画)(九)
Error building sqlsession problem
Us judge ruled that the former security director of Uber accused of covering up hacking must face fraud charges
PostgreSQL database system table
Adobe Premiere Basics - common video effects (corner positioning, mosaic, blur, sharpen, handwriting tools, effect control hierarchy) (16)
Adobe Premiere foundation - material nesting (animation of Tiktok ending avatar) (IX)
第02章_MySQL的数据目录
POJ 1975 (transitive closure)
Adobe Premiere基础-编辑素材文件常规操作(脱机文件,替换素材,素材标签和编组,素材启用,便捷调节不透明度,项目打包)(十七)
Sd6.23 summary of intensive training








