var Begintime_ms = date.parse (New Date (Begintime.replace (/-/g, "/")); BeginTime to start time
var Endtime_ms = date.parse (New Date (Endtime.replace (/-/g, "/")); Endtime to end time
The result is a millisecond number, which can be used to determine the time according to the size of the millisecond.
Of course, according to the number of milliseconds can be based on their difference to find the difference between the number of days or hours.
-------------------------------
The above is the number of milliseconds to obtain the user input time
var date1=new Date (); Start time
var date2=new Date (); End time
var date3=date2.gettime ()-date1.gettime ()//Time difference milliseconds
------------------------------
Calculate the difference in days
var Days=math.floor (date3/(24*3600*1000))
Calculate the number of hours
var leave1=date3% (24*3600*1000)//number of milliseconds remaining after counting days
var Hours=math.floor (leave1/(3600*1000))
Calculate the difference of minutes
var leave2=leave1% (3600*1000)//number of milliseconds remaining after calculating hours
var Minutes=math.floor (leave2/(60*1000))
Count the difference in seconds
var leave3=leave2% (60*1000)//number of milliseconds remaining after counting minutes
var seconds=math.round (leave3/1000)
Alert ("Difference" +days+ "Days" +hours+ "hours" +minutes+ "minutes" +seconds+ "seconds")
The above JS calculation time difference code "including calculations, days, hours, minutes, seconds" is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud habitat community.