Why does this javascript return 108 instead of 2008? it gets the day and month correct but not the year?
myDate = new Date();
year = myDate.getYear();
year = 108?
Why does this javascript return 108 instead of 2008? it gets the day and month correct but not the year?
myDate = new Date();
year = myDate.getYear();
year = 108?
As others have said, it returns the number of years since 1900. The reason why it does that is that when JavaScript was invented in the mid-90s, that behaviour was both convenient and consistent with date-time APIs in other languages. Particularly C. And, of course, once the API was established they couldn't change it for backwards compatibility reasons.
it is returning 4 digit year - 1900, which may have been cool 9+ years ago, but is pretty retarded now. Java's java.util.Date also does this.