博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JS将秒换成时分秒实现代码 [mark]
阅读量:4620 次
发布时间:2019-06-09

本文共 693 字,大约阅读时间需要 2 分钟。

将秒换成时分秒的方法有很多,在本文将为大家介绍下,使用js的具体的实现思路,有需要的朋友可以参考下,希望对大家有所帮助

http://www.jb51.net/article/41098.htm

 

function formatSeconds(value) { var theTime = parseInt(value);// 秒 var theTime1 = 0;// 分 var theTime2 = 0;// 小时 // alert(theTime); if(theTime > 60) {   theTime1 = parseInt(theTime/60);   theTime = parseInt(theTime%60);   // alert(theTime1+"-"+theTime);   if(theTime1 > 60) {     theTime2 = parseInt(theTime1/60);     theTime1 = parseInt(theTime1%60);   } } var result = ""+parseInt(theTime)+"秒"; if(theTime1 > 0) {   result = ""+parseInt(theTime1)+"分"+result; } if(theTime2 > 0) {   result = ""+parseInt(theTime2)+"小时"+result; } return result; }

 

转载于:https://www.cnblogs.com/jshare/p/7776630.html

你可能感兴趣的文章
Php中"{}"大括号的用法总结(转)
查看>>
6.旋转数组的最小数字
查看>>
P1306-斐波那契公约数【矩阵乘法,数论】
查看>>
[React] Refactor a Class Component with React hooks to a Function
查看>>
JavaScript内存优化
查看>>
BZOJ4269: 再见Xor(线性基)
查看>>
BZOJ1059: [ZJOI2007]矩阵游戏(二分图匹配)
查看>>
P3385 【模板】负环
查看>>
2991:2011
查看>>
SQL优化
查看>>
HDU 1069 Monkey and Banana
查看>>
HDU 2084 数塔
查看>>
[bzoj3131]淘金[sdoi2013][数位DP]
查看>>
自制反汇编逆向分析工具 迭代第五版本 (二)
查看>>
平步青云:Windows Azure(二)
查看>>
平步青云:Windows Azure(一)
查看>>
U-Net卷积神经网络
查看>>
python 爬取煎蛋ooxx妹子图
查看>>
hadoop-12-安装ambari-agent
查看>>
重读C#委托、事件有感
查看>>