简体   繁体   中英

DateTime in Safari and Chrome Render different with .ToJSON

Within our application we are trying to pass through a users selected datetime of which is causing issues within different browsers. As an example, running the below in both Chrome, and Safari both output a different time. Chrome honours the BST and yet safari does not

new Date('2020-08-11T11:47:00').toJSON()

Have tried to google, but unable to find any specific examples for this.

Are there any solutions in place to get around this issue?

EDIT

Chrome output:- "2020-08-11T10:47:00.000Z"

Safari output:- "2020-08-11T11:47:00.000Z"

Safari's parser is buggy. '2020-08-11T11:47:00' should be parsed as local, but Safari (up to v 13.1.2 at least) treats it as UTC. Don't use the built–in parser, see Why does Date.parse give incorrect results?

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