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 re
It just makes no sense to me to get part of a year.
Back in the day, when memory was expensive and the Year 2000 was far in the future, it did make sense for people to represent 1975 as 75. In retrospect a short-sighted decision.
date.getFullYear() == date.getYear() + 1900
Its a Y2K thing, basically getYear
method returns the year minus 1900.
so, I encourage to move over to getFullYear
& use that instead.
getYear()
returns year minus 1900
. This has been deprecated for a while now, it's best to use getFullYear()
.