DAG
DAG

Reputation: 6994

Date Object in node.js has some weird behaviour

I was testing around with NODE for a while now and I experienced a strange behaviour of JS Date() object. The getDay() and getMonth() function are returning incorrect results. I thought I messed up somewhat somewhere in my app, but I tested in the console as well and still the same behaviour. Here is the my log of the console:

$ node
> var currentDate = new Date();
undefined
> currentDate
Wed Jun 19 2013 13:54:20 GMT+0200 (CEST)
> currentDate.getDay()
3
> currentDate.getMonth()
5

it seems to off 'a bit'.

I do not now what' s going on and web-research did not help me as well.

Upvotes: 1

Views: 2294

Answers (1)

Guffa
Guffa

Reputation: 700192

The getDay method returns the day of week, so 3 means wednesday.

The getMonth method returns the zero based month, so 5 means june.

Upvotes: 8

Related Questions