Javascript WTF: The Date object

Almost every time I have to deal with the Date object in Javascript I always hit the same WTF.

The documentation is clear but the API has some strange aspects that personally I don’t think reflect the real world and how we naturally handle dates.

For example:
      getDay() returns the day of the week (0-6) leaving getDate() to return 1-31. Personally, I would have imagined getDate() to return DMY with getDay() returning 1-31.
      getMonth() returns 0-11.  Classic computer science with starting the count at 0 while the Gregorian calendar is 1-12. This is also inconsistent with getDate() which starts at 1.
      getYear() returns the year (usually 2-3 digits). For example, 2012 is
obviously 112. You need to use getFullYear() to return 2012. The logic
about how the method came to 112 is found at

JavaScript 1.0 – we love you and you have left an impact in many ways.

Leave a Reply

Your email address will not be published. Required fields are marked *