getMonth() trap in Javascript

by Matti Lehtinen December 14, 2009 19:07

In .NET DateTime.Month returns the month as integer between 1 and 12. Corresponding thing in JavaScript is Date.getMonth() but values are from 0 to 11.

Ok, it is common to start indexing from zero but the confusing part is that JavaScript’s Date.getDate() returns values from 1 to 31 so it is not analogous to getMonth(). Be aware of that trap when playing with dates in JavaScript.

Tags:

JavaScript

Comments

7/4/2010 10:25:18 PM #

Denny Ellerd

Just in case you didn't know... your website looks very unusual in Mozilla on a mac

Denny Ellerd United States

7/5/2010 11:28:28 PM #

Kevin Wenck

This is fascinating! How did you learn this stuff when you were first getting into it?

Kevin Wenck United States

7/6/2010 3:54:22 PM #

Anti-Aging Medicine

This article receives a  thumbs up from over here.

Anti-Aging Medicine United States

7/7/2010 10:36:22 AM #

Nellie Bica

Interesting piece, thanks. Can you explain the third part in a little more detail please?

Nellie Bica United States

7/9/2010 9:20:32 AM #

Bettyann Bossie

Bloed, zweet, maar geen tranen @ eerste optreden ever met 't bandje

Bettyann Bossie United States

7/28/2010 9:12:07 AM #

Beau Basse

I be supposed to actually be working

Beau Basse Taiwan

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen | Modified by Mooglegiant