Documentación offline JavaScript main

Temporal.ZonedDateTime.prototype.month

main Documentación oficial Licencia CC-BY-SA-2.5Descargado el 2026-08-02

En esta página

The month accessor property of {{jsxref("Temporal.ZonedDateTime")}} instances returns a positive integer representing the 1-based month index in the year of this date. The first month of this year is 1, and the last month is the {{jsxref("Temporal/ZonedDateTime/monthsInYear", "monthsInYear")}}. It is calendar-dependent.

The set accessor of month is undefined. You cannot change this property directly. Use the {{jsxref("Temporal/ZonedDateTime/with", "with()")}} method to create a new Temporal.ZonedDateTime object with the desired new value.

For general information and more examples, see {{jsxref("Temporal/PlainDate/month", "Temporal.PlainDate.prototype.month")}}.

Examples#

Using month#

const dt = Temporal.ZonedDateTime.from("2021-07-01[America/New_York]"); // ISO 8601 calendar
console.log(dt.monthCode); // "M07"
console.log(dt.month); // 7

Specifications#

{{Specifications}}

Browser compatibility#

{{Compat}}

See also#

  • {{jsxref("Temporal.ZonedDateTime")}}
  • {{jsxref("Temporal/ZonedDateTime/with", "Temporal.ZonedDateTime.prototype.with()")}}
  • {{jsxref("Temporal/ZonedDateTime/add", "Temporal.ZonedDateTime.prototype.add()")}}
  • {{jsxref("Temporal/ZonedDateTime/subtract", "Temporal.ZonedDateTime.prototype.subtract()")}}
  • {{jsxref("Temporal/ZonedDateTime/year", "Temporal.ZonedDateTime.prototype.year")}}
  • {{jsxref("Temporal/ZonedDateTime/day", "Temporal.ZonedDateTime.prototype.day")}}
  • {{jsxref("Temporal/ZonedDateTime/monthCode", "Temporal.ZonedDateTime.prototype.monthCode")}}
  • {{jsxref("Temporal/ZonedDateTime/daysInMonth", "Temporal.ZonedDateTime.prototype.daysInMonth")}}
  • {{jsxref("Temporal/ZonedDateTime/monthsInYear", "Temporal.ZonedDateTime.prototype.monthsInYear")}}
  • {{jsxref("Temporal/PlainDate/month", "Temporal.PlainDate.prototype.month")}}