当前位置:网站首页>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;
}
边栏推荐
- 【TcaplusDB知识库】TcaplusDB系统用户组介绍
- 美法官裁定,被控掩盖黑客行为的Uber前安全主管必须面对欺诈指控
- Adobe Premiere Basics - general operations for editing material files (offline files, replacing materials, material labels and grouping, material enabling, convenient adjustment of opacity, project pa
- 6.29模拟赛总结
- [how the network is connected] Chapter 3 explores hubs, switches and routers
- Adobe Premiere foundation - opacity (mixed mode) (XII)
- js文本粒子动态背景
- Usage of BeanUtils property replication
- Sd6.24 summary of intensive training
- Source code installation mavros
猜你喜欢

My first experience of remote office | community essay solicitation

美法官裁定,被控掩盖黑客行为的Uber前安全主管必须面对欺诈指控

Servlet学生管理系统(萌新练手版)

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

About microservices

RocketMQ的tag过滤和sql过滤

idea怎么使用?

Apache InLong百万亿级数据流处理

Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)

Servlet student management system (Mengxin hands-on version)
随机推荐
熊猫跑酷js小游戏代码
Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)
Markdown knowledge comes gently
js文本粒子动态背景
My first experience of remote office | community essay solicitation
【TcaplusDB知识库】TcaplusDB单据受理-创建业务介绍
报错[warning] Neural network inference was performed on socket ‘RGB’, depth frame is aligned to socket
SD6.24集训总结
Longest XOR path (dfs+01trie)
JDBC Codes connexes
Markdown common fonts
Adobe Premiere foundation - cool text flash (14)
Adobe Premiere Basics - common video effects (corner positioning, mosaic, blur, sharpen, handwriting tools, effect control hierarchy) (16)
codeforces每日5题(均1700)-第二天
通过 hosts文件配置本地域名
Interview question 10.10 Rank of digital stream
3H proficient in opencv (VIII) - shape detection
您好,请问mysql cdc、和postgresql cdc有官网样例吗?给个链接学习了
Servlet学生管理系统(萌新练手版)
svg画圆路径动画