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
Fundamentals
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?”
Concept
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).
Foundation
📝 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.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Today’s calendar day
new Date().getDate()
Day from fixed date
new Date(2026, 2, 15).getDate() → 15
UTC calendar day
date.getUTCDate()
Weekday (0–6)
date.getDay()
Add 7 days
date.setDate(date.getDate() + 7)
Valid date check
!Number.isNaN(date.getTime())
Compare
📋 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
Hands-On
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.");
setDate accepts overflow: Jan 28 + 7 days becomes Feb 4. This idiom is the classic way to add days without manual month-length tables.
Applications
🚀 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.
Important
📝 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.
Compatibility
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 ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · 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.
Wrap Up
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.
Your foundation for day-of-month reads in JavaScript.
5
Core concepts
📝01
Syntax
date.getDate()
API
🔢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.