其他分享
首页 > 其他分享> > js将秒转换成几天几小时几分几秒

js将秒转换成几天几小时几分几秒

作者:互联网

function getDuration(second) {
    var days = Math.floor(second / 86400);
    var hours = Math.floor((second % 86400) / 3600);
    var minutes = Math.floor(((second % 86400) % 3600) / 60);
    var seconds = Math.floor(((second % 86400) % 3600) % 60);
    var duration = days + "天" + hours + "小时" + minutes + "分" + seconds + "秒";
    return duration;
}

标签:3600,floor,js,几秒,var,second,几小时,86400,Math
来源: https://blog.csdn.net/fly_1c/article/details/94620813