js获取时间差值
1 function GetTime(firstDate, secondDate) { 2 // 1.对时间进行处理 3 var firsttime = Date.parse(firstDate + " 00:00:00"); 4 var secondtime = Date.parse(secondDate + " 00:00:00"); 5 // 2.获取时间间隔 6 var timespan = secondtime - firsttime; 7 // 3.获取天 8 var day = Math.floor(timespan / 1000 / 60 / 60 / 24); 9 // 4.获取小时 10 var hour = Math.floor(timespan / 1000 / 60 / 60); 11 // 5.获取分钟 12 var minute = Math.floor(timespan / 1000 / 60 - hour * 60); 13 // 6.获取秒 14 var second = timespan / 1000 - hour * 60 * 60 - minute * 60; 15 return day + "@" + hour + "@" + minute + "@" + second; 16 }
本文来自博客园,作者:潜龙-勿用,转载请注明原文链接:https://www.cnblogs.com/cyfjjf/p/12088982.html