Esempio
Restituisce il mese:
var d = new Date();
var n = d.getMonth();
Il risultato di n sarà:
Prova tu stesso " Più "Try it Yourself" esempi di seguito.
Definizione e l'utilizzo
Il getMonth() restituisce il mese (from 0 to 11) per la data indicata, in base all'ora locale.
Note: Gennaio è 0, 1 Febbraio è, e così via.
Supporto browser
Metodo | |||||
---|---|---|---|---|---|
getMonth() | sì | sì | sì | sì | sì |
Sintassi
parametri Nessuna
Dettagli tecnici
Valore di ritorno: Un numero, da 0 a 11, che rappresenta il mese Versione JavaScript: 1.0

Altri esempi
Esempio
Restituisce il nome del mese (not just a number) :
var d = new Date();
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var n = month[d.getMonth()];
L'output del codice precedente sarà:
Prova tu stesso "
<JavaScript Data Object