JavaScript getMonth and getDay not returning correct values

M

maflatoun

Hi,

I must be losing my mind why is the following code returning wrong
values?

var d = new Date();
alert(d); -> Fri Apr 7 09:28:18 EDT 2006
alert("Hour:" + d.getHours()); -> 9
alert("Year:" + d.getYear()); -> 2006
alert("Month:" + d.getMonth()); -> 3
alert("Day:" + d.getDay()); -> 5

Thanks
Maz.
 
E

Evertjan.

wrote on 07 apr 2006 in comp.lang.javascript:
I must be losing my mind why is the following code returning wrong
values?

Indeed.

It is correct, please read the specs!
var d = new Date();
alert(d); -> Fri Apr 7 09:28:18 EDT 2006
alert("Hour:" + d.getHours()); -> 9
alert("Year:" + d.getYear()); -> 2006
alert("Month:" + d.getMonth()); -> 3
alert("Day:" + d.getDay()); -> 5

3 = April [0 = January]

5 = Friday [0 = Sunday]

Lookup: getDate()
 
E

Evertjan.

wrote on 07 apr 2006 in comp.lang.javascript:
thanks... I got it... It's early friday morning and I wasn't thinking
:)

Where are you talking about?

This is usenet not email.

Please quote what you are replying to. If you want to post a followup via
groups.google.com, don't use the "Reply" link at the bottom of the article.
Click on "show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
<http://www.safalra.com/special/googlegroupsreply/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top