JavaScript Date getDate() Method

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Day of month

What You’ll Learn

getDate() returns the calendar day of the month (1–31) from a Date object in local time. This guide covers syntax, five examples, comparisons with similar methods, and safe patterns for date math.

01

Syntax

date.getDate()

02

Range

1 – 31

03

Local time

Not UTC

04

vs getDay

Month vs week

05

Add days

setDate pair

06

Validate

Invalid → NaN

Introduction

Dates power scheduling, billing, dashboards, and “posted on” labels. The JavaScript Date object stores an instant in time; getter methods like getDate() break that instant into human-friendly parts using the user’s local timezone.

If you need the weekday name or index, use getDay() instead—getDate() answers “what number day of this month?”

Understanding the getDate() Method

Date.prototype.getDate() is a zero-argument instance method. It never mutates the original Date—it only reads the day-of-month component according to local time rules.

Combine it with getMonth(), getFullYear(), and getHours() to assemble custom formats, or use toLocaleDateString() when locale-aware formatting is enough.

💡
Beginner Tip

Memory hook: getDate = date number on the calendar (15th). getDay = day of the week (Tuesday / 2).

📝 Syntax

JavaScript
dateObj.getDate()

Parameters

  • None.

Return value

  • Integer 1–31 for a valid date in local time.
  • NaN if dateObj is an invalid Date.

⚡ Quick Reference

GoalCode
Today’s calendar daynew Date().getDate()
Day from fixed datenew Date(2026, 2, 15).getDate() → 15
UTC calendar daydate.getUTCDate()
Weekday (0–6)date.getDay()
Add 7 daysdate.setDate(date.getDate() + 7)
Valid date check!Number.isNaN(date.getTime())

📋 getDate() vs Similar Methods

These names look alike but answer different questions. Pick the getter that matches your UI or calculation.

getDate()
1–31

Day of month

getDay()
0–6

Sun = 0

getUTCDate()
UTC day

Timezone-safe read

getTime()
ms epoch

Full instant

Examples Gallery

Open DevTools Console (F12) or use Try-it links. Fixed dates use the constructor form new Date(year, monthIndex, day) to avoid string parsing surprises.

📚 Getting Started

Read the current day-of-month from a new Date.

Example 1 — Get Today’s Day of the Month

Call getDate() on the current date and time.

JavaScript
const today = new Date();
const dayOfMonth = today.getDate();

console.log("Today is day", dayOfMonth, "of the month.");
Try It Yourself

How It Works

new Date() captures “now.” getDate() extracts only the calendar day integer in local time—hours and minutes are ignored for this getter.

📈 Practical Patterns

Fixed dates, validation, formatting, and date arithmetic.

Example 2 — Read a Specific Calendar Day

Build a date with numeric parts (month index 2 = March).

JavaScript
const march15 = new Date(2026, 2, 15);

console.log(march15.getDate());        // 15
console.log(march15.getMonth());       // 2 (March)
console.log(march15.getFullYear());    // 2026
Try It Yourself

How It Works

The constructor new Date(y, m, d) uses local time and zero-based months. getDate() confirms the day component you passed in.

Example 3 — Validate Before Calling getDate()

Guard against invalid Date objects that yield NaN.

JavaScript
function safeGetDate(date) {
  if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
    return null;
  }
  return date.getDate();
}

console.log(safeGetDate(new Date()));           // e.g. 17
console.log(safeGetDate(new Date("not-a-date"))); // null
Try It Yourself

How It Works

getTime() returns NaN on invalid dates. Checking first prevents displaying “day NaN” in UI code.

Example 4 — Build a Friendly Date Label

Combine getters for a readable string (or prefer toLocaleDateString for i18n).

JavaScript
function displayDateInfo(date) {
  const day = date.getDate();
  const month = date.toLocaleString("en-US", { month: "long" });
  const year = date.getFullYear();
  return month + " " + day + ", " + year;
}

console.log(displayDateInfo(new Date(2026, 6, 4)));
// July 4, 2026
Try It Yourself

How It Works

getDate() supplies the numeric day; locale APIs handle month names. For production apps, consider Intl.DateTimeFormat or toLocaleDateString.

Example 5 — Add Days with setDate(getDate() + n)

Shift a date forward seven days; the engine rolls into the next month when needed.

JavaScript
const daysToAdd = 7;
const future = new Date(2026, 0, 28); // Jan 28, 2026

future.setDate(future.getDate() + daysToAdd);

console.log(future.getDate());     // 4
console.log(future.getMonth());    // 1 (February)
console.log(future.getFullYear()); // 2026
Try It Yourself

How It Works

setDate accepts overflow: Jan 28 + 7 days becomes Feb 4. This idiom is the classic way to add days without manual month-length tables.

🚀 Common Use Cases

  • Calendar cells — highlight today with getDate().
  • Due dates — show “due on the 25th” from a Date.
  • Billing cycles — detect month-end with getDate() vs next day.
  • Relative deadlines — add N days via setDate.
  • Form defaults — pre-fill day dropdowns on date pickers.
  • Logging — include day-of-month in custom timestamp strings.

🧠 How getDate() Resolves the Day

1

Internal instant

The Date stores milliseconds since Unix epoch (UTC).

Storage
2

Local conversion

Engine applies the runtime timezone offset.

TZ
3

Extract day

Calendar day-of-month (1–31) is returned as an integer.

getDate
4

Use in UI

Display, compare, or feed into setDate for arithmetic.

📝 Notes

  • getDate() is local; use getUTCDate() when you standardize on UTC.
  • Do not confuse with getDay() (weekday index).
  • Invalid dates propagate NaN—validate first.
  • Month length varies; let setDate handle overflow instead of manual tables.
  • For user-facing strings, prefer locale formatters over hard-coded English month names.
  • Immutable-style code can copy with new Date(date) before mutating via setDate.

Browser & Runtime Support

Date.prototype.getDate() has been available since the first JavaScript Date implementation (ES1). It works in every browser and Node.js.

Baseline · ES1

Date.prototype.getDate()

Supported in Chrome, Firefox, Safari, Edge, Internet Explorer, and all Node.js versions. No polyfill required.

99% Universal API
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Date.getDate() Excellent

Bottom line: Safe everywhere. Watch timezone boundaries when pairing with UTC getters or ISO strings parsed from servers.

Conclusion

getDate() is the straightforward way to read the day-of-month from a JavaScript Date in local time. Pair it with validation, distinguish it from getDay(), and use setDate(getDate() + n) for day-based arithmetic.

Next, learn getDay() for weekday logic, or setDate() to write the day component directly.

💡 Best Practices

✅ Do

  • Validate dates before calling getDate()
  • Use setDate(getDate() + n) to add days
  • Pick UTC getters when storing UTC midnight
  • Prefer numeric constructors for tests
  • Use locale formatters for display strings

❌ Don’t

  • Confuse getDate with getDay
  • Assume all months have 31 days manually
  • Ignore NaN from bad parses
  • Mix UTC ISO strings with local getters blindly
  • Mutate shared Date objects unexpectedly

Key Takeaways

Knowledge Unlocked

Five things to remember about Date.getDate()

Your foundation for day-of-month reads in JavaScript.

5
Core concepts
🔢 02

1–31

Day of month.

Range
🌐 03

Local

Not UTC.

Timezone
🔄 04

+ days

setDate idiom.

Math
05

Not getDay

Week vs date.

Pitfall

❓ Frequently Asked Questions

An integer from 1 to 31 representing the day-of-month in the Date object's local timezone. It is the calendar date (e.g. 15 for the 15th), not the day of the week.
getDate() returns the day of the month (1–31). getDay() returns the day of the week (0–6, where 0 is Sunday). The names are easy to confuse—remember Date vs Day.
getDate() uses local timezone rules. getUTCDate() reads the UTC calendar day. Near midnight or across timezones they can differ by one day.
NaN. Always validate with !isNaN(date.getTime()) or Number.isNaN(date.getTime()) before relying on the result.
No for valid dates—the range is 1–31. If you see NaN, the Date object is invalid. February dates depend on leap years but still stay within 1–29/30/31 for valid Date instances.
Use setDate(getDate() + n). JavaScript normalizes overflow into the next month automatically. Example: date.setDate(date.getDate() + 7) adds seven days.
Did you know?

Adding days is often written as date.setDate(date.getDate() + 7) because setDate automatically adjusts the month and year when the day overflows—no manual leap-year table required.

Continue to getDay()

Learn how to read the day of the week with weekday indexes from 0 (Sunday) to 6 (Saturday).

getDay() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful