Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The with()
method of Temporal.PlainYearMonth
instances returns a new Temporal.PlainYearMonth
object representing this year-month with some fields replaced by new values. Because all Temporal
objects are designed to be immutable, this method essentially functions as the setter for the year-month's fields.
There's no obvious way to create a new Temporal.PlainYearMonth
object that represents the same year-month in a different calendar, so to replace its calendarId
property, you need to convert it to a Temporal.PlainDate
object first using toPlainDate()
, change the calendar, and then convert it back.