Javascript Date using forward-slashes vs hyphens -
this question has answer here:
when i'm creating new date object , pass in date using hyphens
new date("2015-07-02") // thu jul 02 2015 01:00:00 gmt+0100 (ist)
and when use forward slashes
new date("2015/07/02") // thu jul 02 2015 00:00:00 gmt+0100 (ist)
notice time difference: 01:00:00 hyphens , 00:00:00 forward slashes
this breaks code :(
why happening? workaround this? (should set time 00:00:00 when using hyphens?)
i need able compare dates have forward-slashes dates have hyphens , i'm not sure might need compare dates other symbols.
is happening hyphens only?
thanks.
if recent browser can interpret date string iso-8601
- will it.
examples :
yyyy (eg 1997) yyyy-mm (eg 1997-07) yyyy-mm-dd (eg 1997-07-16) yyyy-mm-ddthh:mmtzd (eg 1997-07-16t19:20+01:00) yyyy-mm-ddthh:mm:sstzd (eg 1997-07-16t19:20:30+01:00) yyyy-mm-ddthh:mm:ss.stzd (eg 1997-07-16t19:20:30.45+01:00)
with format, date/time string interpreted utc(!!!).
you should stick "yyyy/mm/dd"
date strings whenever possible
Comments
Post a Comment