当前位置:网站首页>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;
}
边栏推荐
- 535. encryption and decryption of tinyurl / Jianzhi offer II 103 Minimum number of coins
- Adobe Premiere基础-炫酷文字快闪(十四)
- Cannot retrieve repository metadata processing records
- MySQL数据库每日备份并定时清理脚本
- Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)
- 行程卡“摘星”热搜第一!刺激旅游产品搜索量齐上涨
- 3H proficient in opencv (V) - perspective transformation
- Codeworks 5 questions per day (1700 for each) - the next day
- [tcapulusdb knowledge base] tcapulusdb doc acceptance - create business introduction
- Adobe Premiere foundation - material nesting (animation of Tiktok ending avatar) (IX)
猜你喜欢

Adobe Premiere foundation - time remapping (10)

jdbc_相关代码

Configure the local domain name through the hosts file

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

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

Understanding of strong caching and negotiation caching

svg画圆路径动画

Codeworks 5 questions per day (1700 for each) - the next day

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

js文本粒子动态背景
随机推荐
SD6.25集训总结
Stepping on the pit: json Parse and json stringify
保持jupyter notebook在终端关闭时的连接方法
[tcapulusdb knowledge base] tcapulusdb system user group introduction
Configure the local domain name through the hosts file
If the evaluation conclusion of waiting insurance is poor, does it mean that waiting insurance has been done in vain?
Usage of BeanUtils property replication
剑指 Offer 34. 二叉树中和为某一值的路径-dfs法
Adobe Premiere基础-素材嵌套(制作抖音结尾头像动画)(九)
踩坑记:JSON.parse和JSON.stringify
Request header field XXXX is not allowed by access control allow headers in preflight response
【TcaplusDB知识库】TcaplusDB单据受理-创建游戏区介绍
龙canvas动画
BeanUtils属性复制的用法
3H proficient in opencv (VIII) - shape detection
【日常训练】535. TinyURL 的加密与解密
Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)
优雅书写Controller(参数验证+统一异常处理)
SD6.23集训总结
Maximum length of palindrome substring (string hash + binary)