javascript - Get UTC time for different timezone in mysql format -
with dateobj.toisostring().slice(0, 19).replace('t', ' ')
can convert date object mysql datetime format in javascript. timezone considered client's (browser's) timezone.
i want convert date , time of different time-zones (not browser's timezone) utc time , mysql time format.
eg: alice scheduling meeting in new-york sydney. alice enters new-york time input. thought browser's location sydney, javascript code has assume browser's location in new-york , convert date time utc, mysql format.
i can current new-york time with, dateobj.tolocalestring('en-us', { timezone: 'america/new_york'})
. not sure next. seems considering time differences...
anybody knows how this?
so want store date in utc representation of event occurred.
to save: know alice has time zone set specific value, therefore, need convert alice's time zone utc. if alice entered 11:59:59 pm meeting time time stored when occurred in gmt, +4/5 hours depending on whether dst being observed. sounds using solution need function datetimeutc=fromspecifictimezonetoutc(specifictimezonedatetime,'eastern standard time')
dateobj.tolocalestring('en-us', { timezone: '<timezone name gmt>'})
to view: alice has adjusted here time zone info in pst, gmt-8. since know event occurred @ 3:59:59 gmt need function convert utc specific time, pst, yield 7:59:59 pm in alices' changed config. datetimespecific=fromutctospecifictimezone(utctimezonedatetime,'pacific standard time')
in opionion might better served handling conversions on server side have control on tz info. think js might inconsistent because time information based on client computers regional settings, not preferred timezone of operation. plus, time zone info subject change. don't know how js handles changes.
Comments
Post a Comment