Skip to content Skip to sidebar Skip to footer

Why Does GetDay Return Incorrect Values? (javascript)

I tried to get the day of a week with the getDay() function of the Date object in Javascript. In theory it works fine, but sometimes there is a delay in the output, so if the func

Solution 1:

Because the month number is zero based, not one based.

new Date("2009","04","30") creates a Date object for the 30th of may, not the 30th of april.

(The reason why it's zero based is probably historic, i.e. it behaves the same as some method in a different system way back in time...)


Post a Comment for "Why Does GetDay Return Incorrect Values? (javascript)"