JS取整和取模 //以分钟为基数,获取分钟包含的天、小时、分钟 function getCostTime(minutes){ var day=parseInt(minutes/1440); var hour=parseInt(minutes/60); var minute=parseInt(minutes%60); var string_description=day>0?day+"天":""; string_description+=hour>0?hour+"小时":""; string_description+=minute>0?minute+"分钟":""; return string_description; }
//执行 (function(){ var minutes=1426; var time=getCostTime(minutes); alert(time); })();