Dail
Dail

Reputation: 4606

Wrong day paramenter in new Date()?

Could someone explain me, why I get 12 Februray when running the code below?

I saw the days are from 1 to 31, only the months starts with 0

var d = new Date(2100,1,13)
> d
Fri, 12 Feb 2100 23:00:00 GMT

EDIT:

And why this time?? 23:00:00 it should be 00:00:00

Upvotes: 6

Views: 5159

Answers (3)

Lee Kowalkowski
Lee Kowalkowski

Reputation: 11751

Your locale timezone is interfering. Try: new Date(Date.UTC(2100,1,13)).

Upvotes: 9

sgowd
sgowd

Reputation: 2260

The output is based on the GMT zone and not as per your time zone. Adjust your system time to proper time zone, you should be getting correct output. Hope that helps.

Upvotes: 1

Quentin
Quentin

Reputation: 943097

You are setting 13 Feb 2100 CET and getting output in GMT.

Upvotes: 3

Related Questions