so have iso date time need converted string date object. how keep date converting local browser timezone.
new date('2013-07-18t17:00:00-05:00') thu jul 18 2013 18:00:00 gmt-0400 (edt) i want
thu jul 18 2013 17:00:00 gmt-0500 (xx)
you cannot change behavior of javascript because simple way javascript work. happens javascript looks @ time shift, computes matching timestamp, , asks os representation of timestamp in local time zone. key understand here -05:00 not indication of time zone shift utc.
time zones complex beasts arbitrary political decisions. os provides service display time in local time zone, not in other time zones. have take in account things dst pretty hell.
as time management, decent way tackle problem use dedicated library. in javascript, you'll find moment.js , moment.timezone.js helpful.
example http://codepen.io/xowap/pen/xkpkzb?editors=0010
document.write(moment('2013-07-18t17:00:00-05:00').tz('america/new_york').format('lll')); as bonus, ton of formatting/parsing features moment.js.
please note long use iso 8601, date can pinpointed precise moment, , displayed in timezone of liking. in other words, js "converting" date doesn't matter.
Comments
Post a Comment