Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The day
accessor property of Temporal.PlainDate
instances returns a positive integer representing the 1-based day index in the month of this date, which is the same day number you would see on a calendar. It is calendar-dependent.
It generally starts at 1 and is continuous, but not always. If you want to loop through all the days in a month, first use with()
with { day: 1 }
(which sets to the beginning of the month, even if the actual number is not 1
), then repeatedly use add()
with { days: 1 }
, until the month changes.
Note: Usually, the day index only changes when transitioning from one calendar system into another, such as from the Julian to the Gregorian calendar. In practice, all currently built-in calendars are proleptic, meaning the calendar system is extended indefinitely into the past and future. Assuming day
is non-continuous guards against future introductions of non-proleptic calendars.
The set accessor of day
is undefined
. You cannot change this property directly. Use the with()
method to create a new Temporal.PlainDate
object with the desired new value.