2

Possible Duplicate:
Why does Javascript getYear() return 108?
Javascript date.getYear() returns 111 in 2011?

var testDate=new Date("Wed Dec 07 00:00:00 PST 2011")
 testDate.getYear();

for the above statement, I am getting 111 while I expect 2011.

Why am getting 111 only?

0

3 Answers 3

4

getYear is documented to return the year minus 1900, so you are actually getting the expected value. It's also deprecated. Use getFullYear to receive 2011.

Sign up to request clarification or add additional context in comments.

Comments

3

use getFullYear()

var testDate=new Date("Wed Dec 07 00:00:00 PST 2011")
testDate.getFullYear();

Comments

2

The getYear method returns the year minus 1900

Source - MDN

As a better alternative, you can use getFullYear.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.