Date.prototype.getMonth()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Resumen
El método getMonth() devuelve el mes del objeto Date según la hora local, donde el número cero indica el primer mes del año.
Sintaxis
dateObj.getMonth()
Parámetros
Ninguno.
Resultado
El valor devuelto por getMonth() es un entero entre 0 y 11, donde 0 corresponde a Enero, 1 a Febrero y así sucesivamente.
Ejemplos
Usando getMonth()
En el siguiente ejemplo, la segunda línea asigna el valor 11 a la variable mes, basado en el valor del objeto Date
Navidad
.
var Navidad = new Date("December 25, 2014 23:15:30");
var mes = Navidad.getMonth();
console.log(mes); // 11
Especificaciones
Specification |
---|
ECMAScript® 2025 Language Specification # sec-date.prototype.getmonth |
Compatibilidad con navegadores
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getMonth |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support