当前位置:网站首页>JS converts seconds to "2h30min50s" format
JS converts seconds to "2h30min50s" format
2022-06-29 18:37:00 【bidepanm】
formatSeconds(value) {
let theTime = parseInt(value);// The time required for conversion is seconds
let theTime1 = 0;// branch
let theTime2 = 0;// Hours
let theTime3 = 0;// God
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){
// Greater than 24 Hours
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;
}
边栏推荐
- 熊猫跑酷js小游戏代码
- 数据分析基础--预测模型
- When easycvr deploys a server cluster, what is the reason why one is online and the other is offline?
- MySQL数据库每日备份并定时清理脚本
- Error building sqlsession problem
- Sister Juan takes you to learn database -- 5-day dash day4
- Application and practice of DDD in domestic hotel transaction -- Theory
- shell教程之循环语句for,while,until用法
- Error [warning] neural network information was performed on socket 'RGB', depth frame is aligned to socket
- 山东大学项目实训(七)添加导航栏选择城市
猜你喜欢

山东大学项目实训(六)点击事件展示折线图

Stepping on the pit: json Parse and json stringify

jdbc_ Related codes

如何将OAK相机当做网络摄像头使用?

Adobe Premiere foundation - material nesting (animation of Tiktok ending avatar) (IX)

Adobe Premiere foundation - time remapping (10)

Us judge ruled that the former security director of Uber accused of covering up hacking must face fraud charges

svg画圆路径动画

Source code installation mavros

Leetcode 984. String without AAA or BBB (thought of netizens)
随机推荐
Elegant writing controller (parameter verification + unified exception handling)
Adobe Premiere基础-不透明度(蒙版)(十一)
BeanUtils属性复制的用法
Jar包后台启动并输出日志
C Primer Plus 第12章_存储类别、链接和内存管理_代码和练习题
Stepping on the pit: json Parse and json stringify
JDBC Codes connexes
Yolov6+tensorrt+onnx: deployment based on win10+tensorrt8+yolov6+onnx
Understanding of strong caching and negotiation caching
Apache Doris 基本使用总结
Sd6.23 summary of intensive training
剑指 Offer 34. 二叉树中和为某一值的路径-dfs法
mysql — 清空表中数据
Adobe Premiere基础-常用的视频特效(裁剪,黑白,剪辑速度,镜像,镜头光晕)(十五)
[tcapulusdb knowledge base] tcapulusdb doc acceptance - transaction execution introduction
How to use the oak camera on raspberry pie?
Markdown common fonts
Apache InLong百万亿级数据流处理
[tcapulusdb knowledge base] tcapulusdb doc acceptance - Introduction to creating game area
[how the network is connected] Chapter 3 explores hubs, switches and routers