问题
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