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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -