How to convert date of different timezones to GMT 0? Let say I have dates like this
Fri Jan 20 2012 11:51:36 GMT-0500
Fri Jan 20 2012 11:51:36 GMT-0300
Fri Jan 20 2012 11:51:36 GMT+0500
to
Fri Jan 20 2012 06:51:36 GMT
Fri Jan 20 2012 08:51:36 GMT
Fri Jan 20 2012 16:51:36 GMT
these are dates I am getting via new Date().toString()
on different timezones. Is there any js method to detect timezone and convert accordingly?
EDIT: The second three dates are not the GMT converted times of the first three. For example, Fri Jan 20 2012 11:51:36 GMT-0500
in GMT is Fri Jan 20 2012 16:51:36 GMT
not Fri Jan 20 2012 06:51:36 GMT
. GMT-0500 is behind GMT, not ahead, so you have to add the offset to get GMT, not subtract it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…