Calendar dates with Temporal.PlainDate

Limited support Reference ↗

Represent a calendar date without a time or time zone. Temporal.PlainDate is useful for values such as an all-day event date or a birthday.

if (typeof Temporal === 'undefined') {
  console.info('This browser needs a Temporal polyfill.');
} else {
  const date = Temporal.PlainDate.from('2026-12-31');
  const nextDay = date.add({ days: 1 });

  console.log(nextDay.toString()); // 2027-01-01
  console.log(date.toString());    // 2026-12-31 (unchanged)

  const january = Temporal.PlainDate.from('2026-01-31');
  console.log(january.add({ months: 1 }).toString()); // 2026-02-28
}  

Arithmetic returns a new object rather than mutating the original. With the default constrain overflow policy, adding a month to January 31 gives the last valid day of February.

A plain date is not a timestamp or a moment on the global timeline. Use Temporal.Instant for an instant, or Temporal.ZonedDateTime when time-zone-aware date and time behavior is needed.

Temporal has limited stable-browser support. Detect it before use and provide a polyfill or another deliberate fallback in an application. The guard here only reports its absence; it does not implement the missing API.