Today, a simple question has been encountered: based on the two dates provided, travel values are calculated. Think very simple, get two milliseconds of the date, make the difference and then convert to the corresponding units:
The code is as follows:
Get two date interval years function Yeardiff (begindate,enddate) {//date difference of milliseconds var minisecond=enddate.gettime ()-begindate.gettime (); Return Math.floor (minisecond/(24*3600*1000*360)); Interval year//return Math.floor (minisecond/(24*3600*1000)); Interval days}
Normally this is done, but many times we get a string of dates at the front desk (e.g. ' 2008-06-07 '), and then the current date is poor. Normal will convert the previous to the date format, and then the difference:
var begindate= "2008-06-07"; begindate= new Date (begindate); var nowdate=new Date (); var diffyear= yeardiff (begindate,nowdate);
This should be done, pro-test Firefox no problem, ie results: NAN. Later found to be IE in the analysis of begindate transformation when there is a problem.
Begindate = new Date (Begindate.replace (/-/g, "/"));
So ok!! Do not know what the situation, notes
2015-05-05 20:27
JS to find the difference between the two dates, ie and other browser differences