Safari Javascript Date() NaN Issue (yyyy-MM-dd HH:mm:ss)

前端 未结 3 1736
一生所求
一生所求 2020-11-27 19:25

My code is working properly in Google Chrome, but not in Safari.

I figured out that I need to convert yyyy-MM-dd HH:mm:ss to ISO 8601, but

3条回答
  •  情深已故
    2020-11-27 20:11

    I think Jose missed one point here - Do not forget to include Z or else there will be lag of the timezone.

    new Date('2014-02-18T15:00:48') new Date('2014-02-18T15:00:48Z')

    You can use new Date('2014-02-18T15:00:48'.replace(/\s/, 'T')+'Z').

    Refer this for more info - new Date() works differently in Chrome and Firefox

提交回复
热议问题