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

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

asp.net mvc - Cannot display error message on Editor or EditorFor -