http://www.cnblogs.com/heikediguo/articles/2143511.html
/**
* @param {} second
* @return {}
* @desc 秒转化成dd hh:mm:ss
*/
var dateFormat = function(second){
var dd,hh,mm,ss;
second = typeof second === 'string' ? parseInt(second) : second;
if(!second || second < 0){
return;
}
//天
dd = second / (24 * 3600) | 0;
second = Math.round(second) - dd * 24 * 3600;
//小时
hh = second / 3600 | 0;
second = Math.round(second) - hh * 3600;
//分
mm = second / 60 | 0;
//秒
ss = Math.round(second) - mm * 60;
if(Math.round(dd) < 10){
dd = dd > 0 ? '0' + dd : '';
}
if(Math.round(hh) < 10){
hh = '0' + hh;
}
if(Math.round(mm) < 10){
mm = '0' + mm;
}
if(Math.round(ss) < 10){
ss = '0' + ss;
}
return dd + ' ' + hh + ':' + mm + ':' + ss;
};
本文提供了一个JavaScript函数,用于将秒数转换为天、小时、分钟和秒的格式。
815

被折叠的 条评论
为什么被折叠?



