首页 > Web开发 > 详细

js将秒数换算成时分秒

时间:2015-11-12 17:56:48      阅读:281      评论:0      收藏:0      [点我收藏+]

转载自: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>

 

js将秒数换算成时分秒

原文:http://www.cnblogs.com/zrui-xyu/p/4959498.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!