将UTC时间转换为浏览器的本地时间 [英] Convert UTC time to Local time of Browser

查看:122
本文介绍了将UTC时间转换为浏览器的本地时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在获取UTC时间格式,我需要在浏览器的本地时间中更改它.我尝试了以下操作:-

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);

其中 matchData.results [i] .start_time 是我的UTC时间,即 ISODate("2017-03-09T03:30:00Z")

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)

但是我想要的是,如果本地浏览器时间是上午9:00,那么我也可以保持一致,即上午9:00.

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.

推荐答案

您刚刚尝试过:

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

console.log(start_time1)

>>> 2017年3月9日星期四GMT + 0100(巴黎,马德里)

(我是法国人)

这篇关于将UTC时间转换为浏览器的本地时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆