js将秒数换算成时分秒
2015-11-12 16:41
585 查看
转载自:http://jingyan.baidu.com/article/375c8e19a0413925f2a229d2.html
<script language="javascript"> /** * 将秒数换成时分秒格式 * 整理:www.jbxue.com */ function formatSeconds(value) { var theTime = parseInt(value);// 秒 var theTime1 = 0;// 分 var theTime2 = 0;// 小时 if(theTime > 60) { theTime1 = parseInt(theTime/60); theTime = parseInt(theTime%60); 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; } </script>
相关文章推荐
- Javascript设置选中
- js最新手机号码、身份证正则表达式
- 整理15款实用javascript富文本编辑器 转自136go
- Extjs6的TreePane无法使用iconCls图标显示
- js遍历List具体方法说明
- js实现菜单二级联动
- JSON.stringify和JSON.parse用法
- js selection对象使用方法
- IE、Firefox、Chrome 的JS代码兼容注意事项
- js中typeof与instanceof
- JSP中的TAG
- js计时器实现计时setInterval
- js-Higher-base.js
- js-MediumGrade-base.js
- 常用的js方法(手机类型,汉字计数,url参数)
- js分享插件
- Java8 Nashorn JavaScript引擎
- (转)理解Javascript_04_数据模型
- js / ajax 成功提交后怎么跳转到另外一个页面?
- javascript 实现禁止右键,复制,选取文本 (兼容firefox,IE,chrome等主流浏览器)...