Two identical JavaScript dates aren't equal

date, javascript

Solution

It appears this has been addressed already.

To check whether dates are equal, they must be converted to their primitives:

date1.getTime()=== date2.getTime()
//true

Problem

When I create two identical JavaScript `Date` objects and then compare them, it appears that they are not equal. How to I test if two JavaScript dates have the same value? ``` var date1 = new Date('Mon Mar 11 2013 00:00:00'); var date2 = new Date('Mon Mar 11 2013 00:00:00'); console.log(date1 == date2); //false? ``` JS Fiddle available here

Original source

Related problems