JavaScript Date objects provide get* methods to read individual local components such as year, month, day, hour, and minute. Every local getter also has a getUTC* twin when you need timezone-independent UTC values.
Local getters read values in the user's browser or system timezone. Whenever your code processes server logs or API dates across regions, switch to the getUTC* equivalents so every machine sees identical numbers:
| Method | Return Range | Important Detail |
|---|---|---|
getFullYear() |
4-digit year (2026) |
Always use instead of deprecated getYear() |
getMonth() |
0 to 11 |
0 is January, 11 is December |
getDate() |
1 to 31 |
Day of the month |
getDay() |
0 to 6 |
Weekday (0 = Sunday, 6 = Saturday) |
getHours() |
0 to 23 |
24-hour clock format |
getTime() |
Milliseconds | Epoch timestamp since Jan 1, 1970 UTC |
You can also read minutes (getMinutes()), seconds (getSeconds()), and milliseconds (getMilliseconds()) individually when building custom countdown timers or formatting clock displays.
Remember to add 1 to getMonth() whenever displaying human month numbers 1–12, and pad single digits with padStart(2, "0").
const meeting = new Date("2026-11-12T09:05:00Z");
const year = meeting.getUTCFullYear();
const month = String(meeting.getUTCMonth() + 1).padStart(2, "0");
const day = String(meeting.getUTCDate()).padStart(2, "0");
const weekdayNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
const weekday = weekdayNames[meeting.getUTCDay()];
console.log(`Date: ${year}-${month}-${day} (${weekday})`);
console.log("Epoch ms:", meeting.getTime());
getDate() and getDay(): getDate() returns the calendar day (1–31), while getDay() returns the day of the week (0–6).+ 1 on getMonth(): Displaying date.getMonth() directly shows month 10 for November instead of 11.getYear(): Legacy getYear() returns 126 for 2026 (years since 1900). Always call getFullYear().getMonth() start at 0 while getDate() starts at 1?getMonth() was modeled as a zero-based array index so developers could look up months[date.getMonth()], while calendar days naturally begin at 1.
Call date.getTimezoneOffset(), which returns the difference in minutes between UTC and local time (for example, -360 for UTC+6).
getUTC* methods over local getters?Use getUTCFullYear(), getUTCMonth(), and getUTCHours() for server calculations, billing cycles, and logs so local server timezones never skew results.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Experiment with the code from this lesson in our interactive playground.