Get the Current Year, Month, and Day in JavaScript

To read today's year, month, and day, take Temporal.Now.plainDateISO(zone) and read .year, .month (1-based), and .day. Part of UTC vs Local Time.

Why this scenario is tricky

Two legacy traps meet here: getMonth() is 0-based (December is 11), and the bare getters use the host zone, so a server reports the wrong day for part of the world. Temporal's fields are 1-based and you name the zone, so both traps disappear.

1-based fields, explicit zonegetMonth() is 0-based and host-zoned1-based fields, explicit zonenew Date().getMonth()0-based, host zoneplainDateISO(zone).month1-based, chosen zoneTemporal months run 1-12 and you name the zone you mean.

Minimal working solution

import { Temporal } from '@js-temporal/polyfill';
const d = Temporal.Now.plainDateISO('America/New_York');
const { year, month, day } = d; // month is 1..12

Today's fieldsplainDateISO then destructureToday's fieldszoneplainDateISOyear/month/day

Full production version

import { Temporal } from '@js-temporal/polyfill';
function todayFields(zone = 'UTC') {
  const d = Temporal.Now.plainDateISO(zone);
  return { year: d.year, month: d.month, day: d.day, weekday: d.dayOfWeek };
}

Field helperReturn year, month, day, weekdayField helperzoneplainDateISOread fieldsobject

Verification snippet

Current Year/Month/Day assertionsKey cases assert correctlyAssertions that prove the edge caseMarch .month3 (not 2)day1..31zone-specificuser's dayweekday1=Mon

Common pitfalls

Current Year/Month/Day pitfallsCommon mistakes and their fixesWrongRightgetMonth() as 1-12every month off by oneTemporal .month 1-basedmatches the calendarbare getters on serverUTC dayplainDateISO(zone)user's day

Frequently Asked Questions

How do I get the current month number in JavaScript?

Read Temporal.Now.plainDateISO(zone).month, which is 1-based so March is 3. The legacy new Date().getMonth() is 0-based (March is 2), which is the classic source of off-by-one month bugs.

Why does the current day differ between my server and browser?

The bare Date getters use the host zone, and servers usually run in UTC, so late-evening or early-morning users see a different calendar day. Read the fields from Temporal.Now.plainDateISO(userZone) to get their day.