Date.getHours () in JavaScript looks broken for me

This snippet displays 1. Why is this so?

I use the constructor as in new Date(milliseconds) //milliseconds since 1970/01/01. I expect it to be midnight, so it's 0 hours. But why does it return 1?

var milliseconds = 0;
var d = new Date(milliseconds);
alert(d.getHours());
+3
source share
2 answers

Are you in GMT + 1 time zone?

+10
source
var milliseconds = 0;
var d = new Date(milliseconds);
alert(d.getUTCHours()); // returns 0
+3
source

Source: https://habr.com/ru/post/1727622/


All Articles