There are many methods to obtain time difference and time format. The following describes how to use the function code of jquery and js to retrieve
The Code is as follows:
GetDateDiff (start, end, "day ")
/*
* Time Difference obtained, in the format of year-month-day hour: minute: Second or year/month/day hour: minute: Second
* The year, month, and day are in full format, for example, 01:00:00
* Return accuracy: seconds, minutes, hours, days
*/
Function GetDateDiff (startTime, endTime, diffType ){
// Convert the time format of xxxx-xx to the format of xxxx/xx
StartTime = startTime. replace (/-/g ,"/");
EndTime = endTime. replace (/-/g ,"/");
// Converts the computing interval class characters to lowercase letters.
DiffType = diffType. toLowerCase ();
Var sTime = new Date (startTime); // start time
Var eTime = new Date (endTime); // End Time
// Number used as the Divisor
Var pNum = 1;
Switch (diffType ){
Case "second ":
Pnum= 1000;
Break;
Case "minute ":
Pnum= 1000*60;
Break;
Case "hour ":
Pnum= 1000*3600;
Break;
Case "day ":
PNum = 1000*3600*24;
Break;
Default:
Break;
}
Return parseInt (eTime. getTime ()-sTime. getTime ()/parseInt (pNum); // 17jquery.com
}