/** * 返回示例:0 天 4 小时 7 分钟 57 秒 * @param second 毫秒数 * @returns {String} 时间html */ function secondToDayHTML(second){ var time = parseInt(second/1000); var day = parseInt(time/(60*60*24)); var day_eles = time%(60*60*24); var hour = parseInt(day_eles/(60*60)); var hour_else = day_eles%(60*60); var minute = parseInt(hour_else/(60)); var secoud = hour_else%(60); return(day+" 天 "+hour+" 小时 "+minute+" 分钟 "+secoud+" 秒 "); } /** * 返回示例:0 小时 0 分钟 4 秒 * @param second 毫秒数 * @returns {String} 时间html */ function secondToHourHTML(second){ var time = parseInt(second/1000); var hour = parseInt(time/(60*60)); var hour_else = time%(60*60); var minute = parseInt(hour_else/(60)); var secoud = hour_else%(60); return(hour+" 小时 "+minute+" 分钟 "+secoud+" 秒 "); }
来源:https://www.cnblogs.com/excellencesy/p/12213731.html