1 function GetTime(firstDate, secondDate) { 2 // 1.對事件進行處理 3 var firsttime = Date.parse(firstDate + " 00:00:00"); 4 var secondtime = Date.parse(second ...
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 }View Code