1JS Date comparison (Required date format: yyyy-mm-dd)2 3 functionDatebijiao (firstdate, lastdate) {4 vararr = Firstdate.split ("-");5 varFirsttime =NewDate (Arr[0], arr[1], arr[2]);6 varFirsttimes =firsttime.gettime ();7 8 varArrs = Lastdate.split ("-");9 varLasttime =NewDate (Arrs[0], arrs[1], arrs[2]);Ten varLasttimes =lasttime.gettime (); One A if(firsttimes>=lasttimes) { - return false; - } the Else - return true; - } - + - +JS Time comparison (required date format: yyyy-mm-DD Hh:mi:ss) A at functionComptime (firstdate,lastdate) { - varBeginTime = Firstdate; - varEndTime = Lastdate; - varBegintimes = begintime.substring (0, ten). Split ('-'); - varEndtimes = endtime.substring (0, ten). Split ('-'); - inBeginTime = begintimes[1] + '-' + begintimes[2] + '-' + begintimes[0] + ' + begintime.substring (10, 19); -EndTime = endtimes[1] + '-' + endtimes[2] + '-' + endtimes[0] + ' + endtime.substring (10, 19); to +Alert (beginTime + "AAA" +endTime); - alert (Date.parse (EndTime)); the alert (Date.parse (BeginTime)); * varA = (Date.parse (endTime)-Date.parse (BeginTime))/3600/1000; $ if(A < 0) {Panax NotoginsengAlert ("Endtime small!")); -}Else if(A > 0) { theAlert ("Endtime Big!"); +}Else if(A = = 0) { AAlert ("Equal time!")); the}Else { + return' Exception ' - } $}
JS Date Time Comparison