当前位置:网站首页>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 Basics - general operations for editing material files (offline files, replacing materials, material labels and grouping, material enabling, convenient adjustment of opacity, project pa
- 数据分析基础--预测模型
- Understanding of strong caching and negotiation caching
- Sd6.23 summary of intensive training
- How to use the oak camera on raspberry pie?
- POJ 1975 (transitive closure)
- 3H proficient in opencv (VI) - image stacking
- Configure the local domain name through the hosts file
- Sister Juan takes you to learn database -- 5-day dash day4
- /usr/bin/ld: warning: **libmysqlclient. so. 20**, needed by //usr/
猜你喜欢

JWT登录验证

Leetcode 984. String without AAA or BBB (thought of netizens)

龙canvas动画

Request header field xxxx is not allowed by Access-Control-Allow-Headers in preflight response问题

Adobe Premiere基础-不透明度(混合模式)(十二)

Adobe Premiere基础-批量素材导入序列-变速和倒放(回忆)-连续动作镜头切换-字幕要求(十三)

C comparison of the performance of dapper efcore sqlsugar FreeSQL hisql sqlserver, an ORM framework at home and abroad

My first experience of remote office | community essay solicitation

Sword finger offer 34 Path DFS method for binary tree neutralization

js文本粒子动态背景
随机推荐
Let Google search your blog
Configure the local domain name through the hosts file
mysql — 清空表中数据
行程卡“摘星”热搜第一!刺激旅游产品搜索量齐上涨
MySQL - clear data in the table
BeanUtils属性复制的用法
Stepping on the pit: json Parse and json stringify
第02章_MySQL的数据目录
garbage collector
Record that the server has been invaded by viruses: the SSH password has been changed, the login fails, the malicious program runs full of CPU, the jar package fails to start automatically, and you ha
jdbc_ Related codes
2022.6.29-----leetcode.535
Adobe Premiere基础-声音调整(音量矫正,降噪,电话音,音高换挡器,参数均衡器)(十八)
Adobe Premiere foundation - cool text flash (14)
Servlet student management system (Mengxin hands-on version)
jdbc认识上手
美法官裁定,被控掩盖黑客行为的Uber前安全主管必须面对欺诈指控
数据分析--时间序列预测
Failed to allocate graph: myriad device is not opened
Usage of BeanUtils property replication