为什么Date#getHours()返回小时+ 1? [英] Why does Date#getHours() return hour + 1?
本文介绍了为什么Date#getHours()返回小时+ 1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
var feedDataTimestamp = new Date("2014-01-14T00:04:40+0000").getTime();
var parsedDate = new Date(+feedDataTimestamp);
alert(parsedDate.getHours());
但应打印0,而不是1:时间是 00:04: 40
but it should print 0, not 1: time is 00:04:40
推荐答案
因为您(根据您的Stackoverflow个人资料)在意大利,所以您所在的时区是UTC + 1。
Because you (according to your Stackoverflow profile) are in Italy, so your time zone is UTC+1.
您输入的时间戳是UTC + 0。
The time stamp you are inputting is UTC+0.
parsedDate
将在当地时间。
使用 getUTCHours()
方法,如果您想获取UTC时间而不是本地时间。
Use the getUTCHours()
method if you want to get UTC time instead of local time.
这篇关于为什么Date#getHours()返回小时+ 1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文