Back to JavaScript Notes
Topic #319

Date Get Methods

By the end of this lesson, you can read the year, month, day, weekday, and time from a JavaScript Date object using get methods.

What it is

Date get methods are instance methods on a Date object that return numeric parts of the date and time. They do not change the Date; they only read it. Common methods include getFullYear(), getMonth(), getDate(), getDay(), getHours(), getMinutes(), getSeconds(), getMilliseconds(), and getTime(). Related terms include local time, UTC time, epoch milliseconds, and zero-based month.

Why it matters

  • Build calendar interfaces by extracting day, month, and year values.
  • Validate user input, such as checking whether a selected date is in the future.
  • Compare dates by reading components or by using getTime() for a single numeric value.
  • Format dates manually when you need custom output like YYYY-MM-DD.
  • Debug timezone issues by seeing how local get methods differ from UTC get methods.

Syntax or steps

  1. Create or receive a Date object.
  2. Call a get method on that object.
  3. Use the returned number in your logic.
  4. Remember that getMonth() returns 0 for January and getDay() returns 0 for Sunday.
const d = new Date();
const year = d.getFullYear();
const month = d.getMonth() + 1;
const day = d.getDate();

Example

const event = new Date(2026, 0, 15, 14, 30, 45);

console.log(event.getFullYear());      // 2026
console.log(event.getMonth());         // 0
console.log(event.getMonth() + 1);     // 1
console.log(event.getDate());          // 15
console.log(event.getDay());           // 4
console.log(event.getHours());         // 14
console.log(event.getMinutes());       // 30
console.log(event.getSeconds());       // 45
console.log(event.getTime());          // milliseconds since Jan 1 1970 UTC

The constructor new Date(2026, 0, 15, 14, 30, 45) creates a local date for January 15, 2026, at 2:30:45 PM. getFullYear() returns the four-digit year. getMonth() returns 0 because January is the first month in JavaScript’s zero-based month system. getDate() returns the day of the month, while getDay() returns the weekday number. getTime() returns the total milliseconds since the Unix epoch, which is useful for comparisons and calculations.

Common mistakes

  • Forgetting that months are zero-based. If you need a human month, add 1: d.getMonth() + 1.
  • Confusing getDate() with getDay(). getDate() returns the day of the month, such as 15. getDay() returns the weekday, such as 4 for Thursday.
  • Assuming all get methods use UTC. Standard get methods use local time. Use methods like getUTCFullYear() when you need UTC components.
  • Using getTime() when you need a readable part. getTime() is best for timestamps and arithmetic, not for displaying month or day.

When to use it

Use Date get methods when your code needs numeric date parts for logic. Use formatting tools when you need localized display text. Use Date.now() when you only need the current timestamp.

TaskUseWhy
Check if an event is in JanuarygetMonth()Returns 0 for January.
Show “Jan 15, 2026” to a userIntl.DateTimeFormatHandles locale-aware formatting.
Measure elapsed timeDate.now() or getTime()Gives one numeric timestamp.

Practice

Guided exercise: predict the output, then run this code.

const d = new Date(2025, 11, 25, 9, 5, 0);
console.log(d.getFullYear());
console.log(d.getMonth() + 1);
console.log(d.getDate());
console.log(d.getDay());

Expected output: 2025, 12, 25, and 4. December is month index 11, and December 25, 2025 is a Thursday.

Challenge: write a function called isWeekend that takes a Date and returns true if the day is Saturday or Sunday. Hint: check whether getDay() returns 0 or 6.

Quick check

Question: If d.getMonth() returns 11, what month is it?

Answer: December, because JavaScript months are zero-based.

Summary

Date get methods let you read numeric parts of a date without changing it. The most important details are that months start at 0 and weekdays start at Sunday. Use these methods for logic, and use formatting APIs for user-facing text.

Want to go beyond the notes?

Join Coding Now Tech Institute's JavaScript course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Date Get Methods – FAQs

Quick answers about learning Date Get Methods in JavaScript.

This free note from Coding Now Tech Institute explains Date Get Methods in JavaScript — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every JavaScript topic on Coding Now Tech Institute, including Date Get Methods, is 100% free with no signup required.
With focused practice, most students grasp Date Get Methods in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now