Javascript to convert UTC to local time

后端 未结 8 953
暖寄归人
暖寄归人 2020-11-27 06:23

Okay, say JSON parse string UTC date as below:

2012-11-29 17:00:34 UTC

Now if I want to convert this UTC date to my local time, how can I d

相关标签:
8条回答
  • 2020-11-27 07:07

    The solutions above are right but might crash in FireFox and Safari! and that's what webility.js is trying to solve. Check the toUTC function, it works on most of the main browers and it returns the time in ISO format

    0 讨论(0)
  • 2020-11-27 07:13

    This should work

    var date = new Date('2012-11-29 17:00:34 UTC');
    date.toString()
    
    0 讨论(0)
提交回复
热议问题