I was working with JavaScript's Date
object, and somewhere for the first time I needed to extract the year part of the date. What I saw was a weird behavior. It returns 113 instead of 2013 and I can't figure out how these two numbers might be related, except that the last two numbers might be the same.
var date = new Date();
console.log(date.getYear()); // prints 113
console.log(date.getFullYear()); // prints 2013
How these functions are different? And why having a function to getFullYear
?
It just makes no sense to me to get part of a year.