arshaw / xdate

A Modern JavaScript Date Library
http://arshaw.com/xdate/
GNU General Public License v2.0
681 stars 81 forks source link

How to use a client's machine Date Time Object instead of GMT +0 #28

Open razam217 opened 9 years ago

razam217 commented 9 years ago

Whenever I try to convert the date string, it changes the time from GMT+5 (Pakistan Time) to GMT+0, how can I disable this functionality, so that it wouldn't change the time before and after the conversion.

This date: Sun Jan 25 2015 00:40:00 GMT+0500 (Pakistan Standard Time) Sun Jan 25 2015 01:35:00 GMT+0500 (Pakistan Standard Time)

is converted to this date: 2015-01-24T20:35:00.000Z 2015-01-24T19:40:00.000Z

shrekuu commented 9 years ago

@razam217 , About the toJSON, The timezone is always zero UTC offset, as denoted by the suffix "Z". as metioned here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString

Maybe this one could help: https://github.com/mde/timezone-js