bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/JavaScript/Objects, Classes, and Advanced Patterns
JavaScript•Objects, Classes, and Advanced Patterns

JavaScript 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

Formula

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:

Formula

2026 - 05.

Creating a PlainYearMonth Object

Example

const date = new Temporal.PlainYearMonth(2026, 5);

Temporal.PlainMonthDay Properties

Example

const date = new Temporal.PlainYearMonth(2026,5);

The Temporal.PlainYearMonth Format

The

PlainYearMonth object is parsed using the

RFC 9557 format

Formula

(an extension to the ISO 8601 / RFC 3339 format):

Syntax

Yyyy-mm

Or with a calendar (optional):

Formula

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()

Formula

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()

Formula

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

Previous

JavaScript Function bind()

Next

Self-Invoking Functions