0

Writing some unit tests where I'm testing some logic that leverages MomentJS.

However, what is the best way to compare dates?

If I look at my dates, they print the following (I'm in EST):

// vanilla 
var date = new Date('2018-02-10');

// moment
var mDate = new moment('2018-02-10');

// print contents
console.log(date.toUTCString());    // Fri Feb 09 2018 19:00:00 GMT-0500 (EST)
console.log(mDate.toUTCString());   // Sat Feb 10 2018 00:00:00 GMT-0500 (EST)

console.log(date == mDate);         // false
console.log(new Date(date) == new Date(mDate));   //false

Thoughts?

a11smiles
  • 1,190
  • 1
  • 9
  • 21

0 Answers0