Lesson

JS Date Get Methods

10 min reading
Free Course

JavaScript Date Get Methods: Reading Date and Time Parts

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.

Essential Date Getter Methods

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.

Practical Date Component Extraction Example

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());

Common Mistakes to Avoid

  • Confusing getDate() and getDay(): getDate() returns the calendar day (1–31), while getDay() returns the day of the week (0–6).
  • Forgetting + 1 on getMonth(): Displaying date.getMonth() directly shows month 10 for November instead of 11.
  • Using getYear(): Legacy getYear() returns 126 for 2026 (years since 1900). Always call getFullYear().

Frequently Asked Questions

Why does 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.

How do I read the timezone offset in minutes?

Call date.getTimezoneOffset(), which returns the difference in minutes between UTC and local time (for example, -360 for UTC+6).

When should I prefer getUTC* methods over local getters?

Use getUTCFullYear(), getUTCMonth(), and getUTCHours() for server calculations, billing cycles, and logs so local server timezones never skew results.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Try it Yourself

Experiment with the code from this lesson in our interactive playground.

Open Playground
JavaScript Topic Hub

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum