Convert UTC time to Local time of Browser

喜你入骨 提交于 2019-12-25 08:20:18

问题


I am getting UTC time format,I need to change it in Local time of browser.I have tried the following:-

var start_time1= new Date(matchData.results[i].start_time);

where matchData.results[i].start_time is my UTC time i.e. ISODate("2017-03-09T03:30:00Z")

After doing above I am getting:

09:00:00 GMT+0530 (IST)

But what I want is like, if local browser time is 9:00 a.m., it gives me the same, i.e. 9:00 a.m.


回答1:


Did you just try :

var start_time1 = new Date("2017-03-09T03:30:00Z");

console.log(start_time1)

>>Thu Mar 09 2017 04:30:00 GMT+0100 (Paris, Madrid)

(I'm based in France)



来源:https://stackoverflow.com/questions/42596669/convert-utc-time-to-local-time-of-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!