javascript - Date(dateString) constructor inconsistent? -


a = new date('09-01-2013') //sun sep 01 2013 00:00:00 gmt-0400 (edt)  b = new date('2013-09-01') //sat aug 31 2013 20:00:00 gmt-0400 (edt)  b < //true 

i did in node.js repl, v0.10.12

why dates different based on form of datestring?

i can't see how timezone related, since both dates displayed in local timezone , values not equivalent.

the problem new date('09-01-2013') , new date('2013-09-01') use different formats/standards , such parsed differently.

new date('09-01-2013') parsed expect , results in midnight time (in local time zone). however, new date('2013-09-01') parsed iso-8601 date @ utc midnight, utc midnight converted local timezone when displayed (in case edt reflected in 20:00:00, 4 hour difference).

conclusion: use yyyy/mm/dd avoid headaches.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -