JavaScript Temporal PlainYearMonth
Temporal.PlainYearMonth
The Temporal.PlainYearMonth object represents the year and month of an ISO 8601 calendar date, without a day or a time zone (e.g 2026-05).
The Temporal.PlainYearMonth Object
The Temporal.PlainYearMonth object is a time and year object.
It represents the year and month of an ISO 8601 calendar date, without a day or a time zone.
Example: 2026-05.
Creating a PlainYearMonth Object
Temporal.PlainMonthDay Properties
The Temporal.PlainYearMonth Format
The PlainYearMonth object is parsed using the RFC 9557 format (an extension to the ISO 8601 / RFC 3339 format):
Syntax
YYYY-MM
Or with a calendar (optional):
YYYY-MM[u-ca=calendar_id]
PlainYearMonth Methods
| Method | Description |
|---|---|
| from() | Returns a new PlainDate object from another object or a string |
| toPlainDate() | Returns a new PlainDate object |
| with() | Returns a new PlainDate with specified fields modified |
| Arithmetic | |
| add() | Returns a new PlainDate with a duration added |
| subtract() | Returns a new PlainDate with a duration subtracted |
| Comparison | |
| compare() | Returns -1, 0, or 1 from comparing two dates |
| equals() | Returns true if two PlainDate objects are identical |
| since() | Returns the difference since another date |
| until() | Returns the difference until another date |
| Formatting | |
| toJSON() | Returns an RFC 9557 format string for JSON serialization |
| toLocaleString() | Returns a language-sensitive representation of the date |
| toString() | Returns an RFC 9557 format string representation |
| valueOf() | Throws a TypeError (prevents temporals from being converted to primitives) |
PlainYearMonth Properties
| Property | Description |
| calendarID | Calendar system identifier ("iso8601") |
| daysInMonth | The total number of days in that month |
| daysInYear | The total number of days in that year |
| era | The era name of the calendar, if applicable ("gregory") |
| eraYear | The year within the era, if applicable |
| inLeapYear | A boolean indicating if the date falls in a leap year |
| month | The month as an integer (1-12) |
| monthCode | A calendar-specific string code for the month ("M01") |
| monthsInYear | The total number of months in that year |
| year | The year as an integer |