This page is not available in every language. Missing translations are disabled in the language selector.

Quick reference

JavaScript Date Object Cheatsheet

A quick reference guide for JavaScript Date object: instantiation, getters, setters, UTC methods, epoch timestamps, and Intl.DateTimeFormat formatting.

· Published

The JavaScript Date object represents a single moment in time in a platform-independent format with millisecond precision since the Unix Epoch.

Instantiation

const now = new Date();                        // Current time
const fromEpoch = new Date(1731000000000);     // From millisecond timestamp
const fromISO = new Date('2026-11-08T00:00:00Z'); // From ISO 8601 string
const fromParts = new Date(2026, 10, 8, 12, 0, 0); // Month is 0-indexed (10 = November)

Getters & Setters

const d = new Date();

d.getFullYear();      // e.g. 2026
d.getMonth();         // 0 - 11 (0 = January)
d.getDate();          // 1 - 31 (day of the month)
d.getDay();           // 0 - 6 (day of the week, 0 = Sunday)
d.getHours();         // 0 - 23
d.getMinutes();       // 0 - 59
d.getSeconds();       // 0 - 59
d.getMilliseconds();  // 0 - 999
d.getTime();          // Milliseconds since Jan 1, 1970

Prefix any method with UTC for coordinated universal time (e.g., d.getUTCFullYear(), d.getUTCHours()).

Epoch Timestamps & Parsing

const currentMs = Date.now();                // Fast numeric epoch timestamp
const parsedMs = Date.parse('2026-11-08T00:00:00Z');

Formatting with Intl.DateTimeFormat

const date = new Date('2026-11-08T12:30:00Z');

// Localized long date string
new Intl.DateTimeFormat('en-US', {
  dateStyle: 'full',
  timeStyle: 'short'
}).format(date);
// "Sunday, November 8, 2026 at 12:30 PM"

References

Related topics