views:

63

answers:

2

This snippet displays 1. Why is it so?

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

var milliseconds = 0;
var d = new Date(milliseconds);
alert(d.getHours());
+9  A: 

Are you in timezone GMT+1?

Femaref
Oh, yes I am :-)
Josef Sábl
+2  A: 
var milliseconds = 0;
var d = new Date(milliseconds);
alert(d.getUTCHours()); // returns 0
kennebec
Thanks for the tip
Josef Sábl