What is the difference between creating a new date using momentJS versus using Javascript new Date()? -
if console log 2 same result reason result of third console false means there difference! appreciated.
console.log(new date()); console.log(moment(new date()).todate()); console.log(moment(new date()).todate() == new date());
the following result on console:
wed jul 08 2015 15:55:30 gmt-0500 (central daylight time) wed jul 08 2015 15:55:30 gmt-0500 (central daylight time) false
you comparing date
objects, should comparing values:
console.log(moment(new date()).todate().gettime() == (new date()).gettime()); console.log(+(moment(new date()).todate()) == +(new date()));
more discussion on here: compare 2 dates javascript
Comments
Post a Comment