简体   繁体   中英

JSON Date attribute is parsed to local time zone after storing in JSONStore

Date string should not be converted to local time zone. We want to show the user the date in which record is created. Due to timezone changes we have observed that date is changing.

In web we are removing the time zone so that we we are able to show the date as is.

When we get data from server we are not getting the time zone (Its GMT time). But after saving to jsonstore its getting converted to local time zone and due to that date is getting changed in some cases.

Data received from server - "2019-06-13T00:00:00-05:00"

Data received from json store - "2019-06-13T10:30:00+05:30"

Expected result - "2019-06-13T00:00:00-05:00"

JSONStore stores data as, well, JSON. JSON doesn't have a Date format while JavaScript objects do.

So, when you're writing to the JSONStore, you should convert it to a suitable format that you want - either String or time since epoch. If you convert to String, you can read it out from JSONStore as-is, but the drawback is that you cannot do arithmetic operations on the date without making another conversion.

If you store the time since epoch, you will have to convert it to the desired time zone and then display to your users.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM