How to check if one DateTime is later than another in javascript

datetime, javascript, validation

Solution

Asuming you received a date in Javascript Date format you need `Date.parse()` function or compare by comparison operators. It will return the milliseconds that have passed since 01/01/1970 00:00

Somehow like this:

if(Date.parse(datetimeStart) < Date.parse(datetimeEnd)){
   //start is less than End
}else{
   //end is less than start
}

Here is a Fiddle

Problem

Through the form i am getting two values like ``` Start datetime = '01/12/2013 12:00:00 AM' and End datetime = '02/12/2013 12:00:00 AM'. ``` How I can validate the start datetime must be less than end datetime in javascript?

Original source

Related problems