Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong day paramenter in new Date()?

Tags:

javascript

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

like image 810
Dail Avatar asked Feb 15 '12 09:02

Dail


3 Answers

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

like image 146
Lee Kowalkowski Avatar answered Oct 22 '22 02:10

Lee Kowalkowski


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

like image 27
Quentin Avatar answered Oct 22 '22 02:10

Quentin


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.

like image 42
sgowd Avatar answered Oct 22 '22 03:10

sgowd