-
Notifications
You must be signed in to change notification settings - Fork 8k
/
index.md
50 lines (30 loc) · 954 Bytes
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
title: Date.prototype.getMonth()
slug: Web/JavaScript/Reference/Global_Objects/Date/getMonth
---
{{JSRef}}
## 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 {{jsxref("Date")}} `Navidad`.
```js
var Navidad = new Date("December 25, 2014 23:15:30");
var mes = Navidad.getMonth();
console.log(mes); // 11
```
## Especificaciones
{{Specifications}}
## Compatibilidad con navegadores
{{Compat}}
## Vea también
- {{jsxref("Date.prototype.getUTCMonth()")}}
- {{jsxref("Date.prototype.setMonth()")}}