Working with dates and times is one of the most frustrating aspects of JavaScript development. The built-in Date object has been part of the language since 1995, yet developers still struggle with timezone conversions, month indexing starting at zero, inconsistent parsing behavior, and the lack of a proper date-only or time-only type. Every web application — from booking systems to analytics dashboards to social media feeds — needs to handle dates. Whether you are formatting a timestamp for display, calculating the difference between two dates, or converting between timezones, the JavaScript Date API is both essential and maddening. Our free interactive JavaScript Date/Time methods cheat sheet cuts through the confusion. It organizes every method into searchable categories, provides concise syntax references, live code examples, and clear labels for static versus instance methods, UTC variants, and locale-aware operations. It even includes a preview of the upcoming Temporal API — the modern replacement for Date. Everything runs client-side in your browser.
Why Developers Need a JavaScript Date/Time Cheat Sheet
The JavaScript Date object is notoriously quirky. Months are zero-indexed (0 = January) while days are one-indexed (1 = first day). The default toString() output varies by browser. Parsing a date string with new Date('2026-05-13') creates a different result than new Date(2026, 4, 13) because the former treats the input as UTC and the latter as local time. These inconsistencies lead to bugs that are difficult to diagnose.
The real problem is retrieval friction. When you need to remember whether getDay() returns the day of the month or the day of the week, or how to format a date in a specific timezone without pulling in a 20KB library, you lose time and focus. A well-organized js datetime cheat sheet reduces that friction to seconds. Our interactive version goes further — it lets you search by method name, filter by category (constructors, getters, setters, formatting, timezone, patterns, Temporal API), and copy code examples instantly.
JavaScript Date Basics: A Quick Review
The Date object represents a single moment in time as the number of milliseconds since the Unix Epoch (January 1, 1970, 00:00:00 UTC). Internally, every Date stores just one number — a timestamp. All the getters, setters, and formatters are convenience methods layered on top of this single numeric value.
const now = new Date();
console.log(now.getTime()); // e.g. 1778767200000
// The same moment, created differently
const fromString = new Date('2026-05-13T14:30:00Z');
const fromComponents = new Date(Date.UTC(2026, 4, 13, 14, 30));
const fromTimestamp = new Date(1778767200000);
console.log(fromString.getTime() === fromComponents.getTime()); // true
Because a Date is just a timestamp, it has no concept of timezone attached to it. The timezone only comes into play when you format the date for display. This distinction — timestamp versus formatted string — is the key to understanding JavaScript dates.
Creating Dates: Constructor and Static Methods
There are four ways to create a Date object, plus three important static methods on the Date constructor itself.
new Date() — Current Time
const now = new Date();
console.log(now); // "Tue May 13 2026 14:30:00 GMT+0800"
new Date(value) — From Timestamp
const epoch = new Date(0); // 1970-01-01T00:00:00Z
const later = new Date(1715587200000); // 2024-05-13T08:00:00Z
new Date(dateString) — From ISO String
const d1 = new Date('2026-05-13');
const d2 = new Date('2026-05-13T14:30:00Z');
// Caution: parsing behavior varies by engine
// Always use ISO 8601 for consistency
new Date(year, month, day, ...) — From Components
// Month is 0-indexed! 4 = May
const d = new Date(2026, 4, 13, 14, 30);
// Creates local time: May 13, 2026 14:30:00
Date.now() — Current Timestamp
const start = Date.now();
// ... do work
const end = Date.now();
console.log(`Took ${end - start}ms`);
Date.parse() and Date.UTC()
const ms = Date.parse('2026-05-13T00:00:00Z');
const utcMs = Date.UTC(2026, 4, 13, 14, 30); // Treats as UTC
Getters: Extracting Date Components
JavaScript provides two complete sets of getters: one for local time and one for UTC. This duality is the source of much confusion but also the mechanism for timezone-aware applications.
Local Time Getters
const d = new Date();
d.getFullYear(); // 2026
d.getMonth(); // 0-11 (0 = January)
d.getDate(); // 1-31 (day of month)
d.getDay(); // 0-6 (0 = Sunday)
d.getHours(); // 0-23
d.getMinutes(); // 0-59
d.getSeconds(); // 0-59
d.getMilliseconds(); // 0-999
UTC Getters
const d = new Date('2026-05-13T14:30:00Z');
d.getUTCHours(); // 14 (always UTC)
d.getHours(); // local hour (varies by timezone)
Other Useful Getters
d.getTime(); // Timestamp in ms
d.getTimezoneOffset(); // Offset from UTC in minutes
// e.g. -480 for GMT+0800, 300 for GMT-0500
Setters: Modifying Date Components
Setters mutate the Date object in place and return the new timestamp. Like getters, there are local and UTC variants for every component.
const d = new Date();
d.setFullYear(2030);
d.setMonth(11); // December
d.setDate(25);
d.setHours(14, 30, 0);
// UTC setters
d.setUTCHours(14);
// setTime replaces the entire timestamp
d.setTime(0); // Reset to Unix Epoch
Formatting Methods
Formatting is where the Date object shines — and where most developer pain originates. Here are the built-in methods and when to use each.
toISOString() — The Gold Standard
const d = new Date('2026-05-13T14:30:00Z');
console.log(d.toISOString()); // "2026-05-13T14:30:00.000Z"
// Always 24 or 27 characters, always UTC
toLocaleString() — Locale-Aware Formatting
const d = new Date('2026-05-13T14:30:00');
// US format
console.log(d.toLocaleDateString('en-US')); // "5/13/2026"
// German long format
console.log(d.toLocaleDateString('de-DE', {
weekday: 'long', year: 'numeric',
month: 'long', day: 'numeric'
}));
// "Dienstag, 13. Mai 2026"
// Time only
console.log(d.toLocaleTimeString('en-US', {
hour: '2-digit', minute: '2-digit'
}));
// "02:30 PM"
Intl.DateTimeFormat — Reusable Formatters
const formatter = new Intl.DateTimeFormat('en-US', {
year: 'numeric', month: 'short', day: '2-digit'
});
console.log(formatter.format(new Date('2026-05-13')));
// "May 13, 2026"
Other Formatting Methods
d.toDateString(); // "Tue May 13 2026"
d.toTimeString(); // "14:30:00 GMT+0800"
d.toUTCString(); // "Wed, 13 May 2026 14:30:00 GMT"
d.toString(); // Full local string
Timezone Handling
Timezones are the most common source of date-related bugs. The key insight is: store and transmit UTC, display in the user's local timezone or a specified zone.
// Display in any IANA timezone
const d = new Date('2026-05-13T14:30:00Z');
console.log(d.toLocaleString('en-US', {
timeZone: 'America/New_York'
}));
// "5/13/2026, 10:30:00 AM"
// Reusable timezone formatter
const nyFormatter = new Intl.DateTimeFormat('en-US', {
timeZone: 'America/New_York',
dateStyle: 'full', timeStyle: 'long'
});
Common Patterns
Beyond individual methods, developers need recipes for common operations. Our cheat sheet includes ten essential patterns.
Add or Subtract Days
function addDays(date, days) {
const result = new Date(date);
result.setDate(result.getDate() + days);
return result;
}
Compare Dates
const d1 = new Date('2026-05-13');
const d2 = new Date('2026-05-14');
console.log(d1 < d2); // true (coerces to numbers)
function isSameDay(a, b) {
return a.toDateString() === b.toDateString();
}
Start/End of Day, Week, Month
function startOfDay(date) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
}
function endOfMonth(date) {
return new Date(date.getFullYear(), date.getMonth() + 1, 0);
}
Format Relative Time
const rtf = new Intl.RelativeTimeFormat('en', { numeric: 'auto' });
console.log(rtf.format(-2, 'hour')); // "2 hours ago"
console.log(rtf.format(3, 'day')); // "in 3 days"
Check Leap Year and Days in Month
function isLeapYear(year) {
return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0);
}
function daysInMonth(year, month) {
return new Date(year, month + 1, 0).getDate();
}
Temporal API Preview
The Temporal API is the future of date/time handling in JavaScript. It addresses every major flaw in the Date object: mutability, month-zero indexing, ambiguous timezone handling, and the lack of date-only or time-only types.
// Current instant (no timezone)
const now = Temporal.Now.instant();
// Current date only
const today = Temporal.Now.plainDateISO();
// Date and time in a specific zone
const ny = Temporal.Now.zonedDateTimeISO('America/New_York');
// Immutable manipulation
const tomorrow = today.add({ days: 1 });
// Duration
const delay = Temporal.Duration.from({ hours: 2, minutes: 30 });
// Unambiguous datetime
const meeting = Temporal.ZonedDateTime.from({
year: 2026, month: 5, day: 13,
hour: 14, minute: 30,
timeZone: 'America/New_York'
});
As of 2026, Temporal is a Stage 3 TC39 proposal. It is available in some browsers behind flags and via polyfills. Expect native support within the next one to two years.
Quick Reference Summary
| Category | Key Methods |
|---|---|
| Construction | new Date(), Date.now(), Date.parse(), Date.UTC() |
| Local Getters | getFullYear, getMonth, getDate, getDay, getHours, getMinutes, getSeconds, getMilliseconds |
| UTC Getters | getUTCFullYear, getUTCMonth, getUTCDate, getUTCDay, getUTCHours, getUTCMinutes, getUTCSeconds, getUTCMilliseconds |
| Setters | setFullYear, setMonth, setDate, setHours, setMinutes, setSeconds, setMilliseconds, setTime |
| Formatting | toISOString, toLocaleString, toLocaleDateString, toLocaleTimeString, toDateString, toTimeString, toUTCString |
| Timezone | getTimezoneOffset, Intl.DateTimeFormat with timeZone option |
| Conversion | getTime, valueOf, Symbol.toPrimitive |
| Patterns | addDays, compareDates, startOfDay, startOfWeek, startOfMonth, relativeTime, leapYear, daysInMonth, dateDiff, ISOWeek |
| Temporal (future) | Temporal.Now.instant, Temporal.Now.plainDateISO, Temporal.Now.zonedDateTimeISO, Temporal.Duration, Temporal.PlainDate, Temporal.ZonedDateTime |
Try Our Interactive JavaScript Date/Time Methods Cheat Sheet
Reading about Date methods is helpful, but having an interactive reference at your fingertips is transformative. Our free JavaScript Date/Time Methods Cheat Sheet puts every method into a searchable, filterable interface with these features:
- Real-time search — find methods by name, description, or example
- Category filtering — narrow to constructors, getters, setters, formatting, timezone, patterns, or Temporal API
- Method badges — instantly see static, instance, UTC, locale, pattern, and Temporal labels
- Syntax highlighting — code examples are color-coded for readability
- One-click copy — copy any code example to your clipboard instantly
- 100% client-side — no data leaves your browser
Related Developer Tools
- JavaScript Array Methods Cheat Sheet — Interactive reference for 40+ array methods with search, filter, and copy.
- JavaScript String Methods Cheat Sheet — Interactive reference for 45+ string methods.
- React Hooks Cheat Sheet — Interactive reference for 20+ built-in hooks and 10 custom patterns.
- Timestamp Converter — Convert Unix timestamps to human-readable dates and back.
- JavaScript Minifier & Beautifier — Compress JS for production or prettify minified code.
- Node.js Built-in Modules Cheat Sheet — 70+ Node.js APIs across fs, path, http, events, stream, buffer, crypto, os, and more.
Frequently Asked Questions
What is the difference between getDate() and getDay() in JavaScript?
getDate() returns the day of the month (1-31), while getDay() returns the day of the week (0-6, where 0 is Sunday). They are easy to confuse because of their similar names, but they return completely different values.
How do I format a date in JavaScript without using Moment.js?
Modern JavaScript provides several built-in options: toLocaleDateString() and toLocaleString() for locale-aware formatting, toISOString() for UTC ISO 8601 format, and Intl.DateTimeFormat for reusable formatters. For custom formats, combine getter methods with string interpolation. The Temporal API will provide even more robust date formatting in the future.
What is the Temporal API and when will it be available?
The Temporal API is a modern replacement for the JavaScript Date object. It provides immutable date/time types with no ambiguity between local and UTC time. As of 2026, Temporal is a Stage 3 TC39 proposal and is available behind flags in some browsers or via polyfills. Expect native support within the next one to two years.
How do I handle timezones in JavaScript?
Use toLocaleString() or Intl.DateTimeFormat with the timeZone option to display dates in specific IANA timezones. For conversions, work with UTC timestamps using getTime(). getTimezoneOffset() returns the difference between local time and UTC in minutes. Avoid manual timezone math when possible.
Is the JavaScript Date/Time Methods Cheat Sheet free to use?
Yes. The DevToolkit JavaScript Date/Time Methods Cheat Sheet is completely free with no limits, no registration, and no advertisements. It runs entirely in your browser with no data sent to any server.
Conclusion
JavaScript dates are powerful but full of sharp edges. From zero-indexed months to ambiguous string parsing to the local versus UTC duality, the Date API demands careful attention. Our free interactive JavaScript Date/Time methods cheat sheet removes the guesswork. Whether you are formatting a timestamp for international users, calculating date differences for a booking system, or preparing for the arrival of the Temporal API, the cheat sheet puts every method, pattern, and example at your fingertips. Bookmark it, share it with your team, and never wrestle with JavaScript dates again.