Date.getMonth() (Method)

Returns the month value of a date/time.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Property/method value type:Number primitive
JavaScript syntax:-myDate.getMonth()

The month number for the receiving date object is returned. This is a zero based value in the range 0 to 11 inclusive. The value 0 represents January, and 11 represents December.

The value is in local time coordinates.

Example code:

   <HTML>

   <HEAD></HEAD>

   <BODY>

   <SCRIPT>

   myDate  = new Date();

   myMonth = myDate.getMonth();

   egyptianCalendar(myMonth);

   // Generate attributes of the Egyptian calendar based on month

   function egyptianCalendar(aMonth)

   {

   mySeasonArray = new Array("Akhet", "Peret", "Shemu");

   myMonthArray  = new Array("I", "II", "III", "IV");

   myNameArray   = new Array("Thoth", "Phaophi", "Athyr", "Choiak", "Tybi", "Mechir", "Phamenoth", "Pharmuthi", "Pachons", "Payni", "Epiphi", "Mesore");

   myDeityArray  = new Array("Tekhi", "Ptah-aneb-res-f", "Het-hert", "Sekhet", "Amsu", "Rekeh-ur", "Rekeh-netches", "Rennutet", "Khensu", "Kenthi", "Apt", "Heru-khuti");

   myTypeArray   = new Array("F", "M", "F", "F", "M", "M", "M", "F", "M", "M", "F", "M");

   mySeason = mySeasonArray[Math.floor(aMonth/4)];

   myMonth  = myMonthArray[aMonth%4];

   myName   = myNameArray[aMonth];

   myDeity  = myDeityArray[aMonth];

   switch(myTypeArray[aMonth])

   {

   case "F" : myType = "Goddess";

   break;

   case "M" : myType = "God";

   break;

   }

   document.write("Index : "  + aMonth   + "<BR>");

   document.write("Season : " + mySeason + "<BR>");

   document.write("Month : "  + myMonth  + "<BR>");

   document.write("Name : "   + myName   + "<BR>");

   document.write("Deity : "  + myDeity  + "<BR>");

   document.write("Type : "   + myType   + "<BR>");

   }

   </SCRIPT>

   </BODY>

   </HTML>

See also:Date.prototype, Date.setMonth(), Date.setUTCMonth()

Cross-references:

ECMA 262 edition 2 - section - 15.9.5.8

ECMA 262 edition 3 - section - 15.9.5.12