Reputation: 2692
How does this happen?
var d = new Date(2014, 0, 0, 0, 0 , 0, 0);
assert(d.getTime()/1000 == 1388534400); // somehow, this results in assert(1388466000 == 1388534400)
Why wouldn't d be Wed, Jan 1st, 2014 00:00:00 GMT, rather than Tue, 31 Dec 2013 05:00:00 GMT
Upvotes: 0
Views: 43
Reputation: 41958
Date
is localized and follows the timezone of your local computer. Apparently you're in a GMT+5 timezone, and as the other answer points out the day off is explained by the 1-based offset of days.
Upvotes: 3
Reputation: 413682
Day of month is numbered from 1, not 0. Day 0 of a month is the last day of the previous month.
Also note that the API your using is going to construct a date in the local time zone. Even if you construct a date for 1 Jan 2014, it will only look like midnight GMT on that date if your local time zone is GMT.
Upvotes: 6