Pandelon
Pandelon

Reputation: 607

Node.js Date command creates incorrect date

I was experimenting with creating new dates in Node.js; for some reason it is giving me dates that are one day out.

date = new Date("17 Jul 1990");
Fri, 16 Jul 1990 23:00:00 GMT

huh???

Edit: I am using Node.js for windows v0.6.5, just downloaded and installed today.

Upvotes: 1

Views: 2644

Answers (1)

user1046334
user1046334

Reputation:

It is not one day, it one hour (look better). And it did it ok. It took your machine local timezone into account, but the string result shows GMT.

And it is only because what is written down in node REPL is util.inspect(x) (which uses toUTCString()), not x.toString().

Just try date.toString() and you'll see everything is perfectly correct.

Upvotes: 3

Related Questions