Dates and times appear in almost every app — logs, bookings, countdowns, and APIs. This hub links to 46 Date method tutorials for reading parts, mutating values, formatting strings, and working in UTC.
01
new Date
Create dates
02
get*
Read parts
03
set*
Change parts
04
UTC
Global time
05
Format
toISOString
06
46 guides
Full index
Fundamentals
Introduction
JavaScript provides a built-in Date object for working with moments in time. Unlike many languages, months are zero-based (0 = January), and the object is mutable — setters change the same instance.
What Are Date Methods?
Date methods fall into a few groups: getters read year, month, day, and clock fields; setters update them; formatters produce strings; and static helpers like Date.now() and Date.parse() work without an instance.
💡
Beginner Tip
Store and exchange times as UTC timestamps or ISO strings (toISOString()). Convert to local display only at the UI layer with toLocaleString().
Local Time vs UTC
Local — getHours(), setMonth() use the user’s timezone.
UTC — getUTCHours(), setUTCDate() ignore local offset.
Timestamp — getTime() and Date.now() return milliseconds since the epoch (timezone-agnostic).
Foundation
📝 Syntax
Create and inspect a date:
JavaScript
const now = new Date();
const timestamp = Date.now();
console.log(now.getFullYear()); // local year
console.log(now.getUTCMonth()); // UTC month (0–11)
console.log(now.toISOString()); // "2026-07-17T10:30:00.000Z"
Method groups
Group
Examples
Purpose
Static
Date.now(), Date.parse()
Timestamps without an instance
Getters
getDate(), getMonth()
Read components
Setters
setHours(), setFullYear()
Mutate the Date
Format
toISOString(), toLocaleDateString()
Human or API strings
Cheat Sheet
⚡ Quick Reference
Goal
Method
Current timestamp
Date.now()
Day of month
date.getDate() (1–31)
Month (remember 0-based)
date.getMonth()
API string (UTC)
date.toISOString()
Locale display
date.toLocaleDateString()
Add days
date.setDate(date.getDate() + n)
Context
When to Use Which Methods
Now — Date.now() for performance timing or unique IDs.
Parse user input — new Date(string) or Date.parse() (validate results — parsing is inconsistent for some formats).
Display — toLocaleDateString() / toLocaleTimeString() for UI.
APIs & databases — toISOString() for JSON payloads.
Math across days — convert to timestamps with getTime(), add milliseconds, create new Date(ms).
Preview
👀 Sample Date Output
Different methods format the same moment differently:
setDate() normalizes overflow — adding 7 to July 28 lands in August automatically. For complex calendar rules, consider libraries like Temporal (future) or date-fns.
Tips
💬 Usage Tips
Timezone awareness — document whether UI shows local or UTC; use UTC getters for server sync.
Validate parsed dates — isNaN(date.getTime()) detects invalid Date objects.
Prefer ISO in JSON — JSON.stringify calls toJSON() → ISO string.
Avoid string parsing traps — new Date("2026-07-17") may parse as UTC midnight; test your format.
Search this index — jump to any of 46 method pages above.
Watch Out
⚠️ Common Pitfalls
Zero-based months — July is 6, not 7, in getters and the constructor.
Mutable dates — setters change the original object; clone first if needed.
Daylight saving jumps — local setHours() can skip or repeat hours on DST boundaries.
Legacy Date.parse — implementation-dependent for non-ISO strings; prefer explicit parsing.
Sort as strings — compare getTime() numbers, not formatted date strings.
🧠 How Date Methods Work
1
Internal timestamp
Every Date stores milliseconds since 1 Jan 1970 00:00:00 UTC.
Epoch
2
Getters / setters
Methods project that instant into local or UTC calendar fields.
Project
3
Formatters
toISOString and locale methods produce strings for display or transport.
Format
=
📅
Time-aware apps
Schedules, logs, and deadlines become manageable with the right method for each job.
Compatibility
Browser Support
The Date object and its methods are part of core JavaScript — supported in every browser and Node.js version. Locale formatting depends on the host’s Intl implementation; ISO methods behave consistently everywhere.
✓ Baseline · ES1+
Date.prototype methods
Supported in Chrome, Firefox, Safari, Edge, IE 3+, and all modern Node.js versions. Static helpers like Date.now() are universally available in current runtimes.
100%Core API
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
Date methodsUniversal
Bottom line: Production-safe across all modern and legacy environments. Prefer toISOString() for APIs and toLocaleString() for user-facing display.
Wrap Up
🎉 Conclusion
JavaScript Date methods give you full control over reading, changing, and formatting moments in time. Start with Date.now(), getters, and toISOString(), then explore UTC and locale APIs as needed.
Use the searchable index to open all 46 tutorials — each includes try-it labs and FAQs.
Date represents a single moment in time internally as milliseconds since the Unix epoch (1 Jan 1970 UTC). You create one with new Date(), Date.now(), or Date.parse(), then use getters and setters to read or change components.
getHours() and setHours() use the user's local timezone. getUTCHours() and setUTCHours() use Coordinated Universal Time. Use UTC methods when storing or comparing times across timezones.
JavaScript Date months are zero-based: 0 = January through 11 = December. Always add 1 when displaying to users unless you format with toLocaleDateString.
Use date.toISOString() for a standard UTC string like 2026-07-17T10:30:00.000Z. For user-facing text, prefer toLocaleDateString() or toLocaleString() with a locale and options.
Yes. setDate(), setHours(), and other setters change the same Date instance in place and return the new timestamp (milliseconds). Clone with new Date(date.getTime()) before mutating if you need the original.
Read the overview, try the five examples, then open getDate() or Date.now() from Getting Started. Use the search box to find any of the 46 method tutorials.
Did you know?
valueOf() and getTime() both return the millisecond timestamp, so comparing dates with > works because JavaScript calls valueOf() when coercing Dates to numbers.