I'm following Daniel's answer here : Compare two dates with JavaScript
But it's not working as is should. This is my code:
selectedDateEnd
is a date selected from jQuery UI Datepicker
controller
is the a date from a list (last date added (in the future))
12096e5
is a magic number which is 14 days in milliseconds.
A user can only create a new item that is 14 days older than the last item created.
if(+selectedDateEnd >= (+controller + 12096e5)){
cl('selectedDateEnd >= controller');
cl(selectedDateEnd + ' >= ' + controller);
} else {
cl('selectedDateEnd < controller');
cl(selectedDateEnd + ' < ' + controller);
}
And the output is this:
selectedDateEnd < controller
Thu Feb 12 2015 00:00:00 GMT+0100 < Thu Feb 12 2015 00:00:00 GMT+0100
According to the logic, it should output:
Thu Feb 12 2015 00:00:00 GMT+0100 >= Thu Feb 12 2015 00:00:00 GMT+0100
What have I done wrong here? See my fiddle: http://jsfiddle.net/ueoxv9w7/