JavaScript Date.now() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Date

Definition

Date.now() is a static method that returns the number of milliseconds since January 1, 1970 UTC (the Unix epoch) at the moment you call it. You do not need new Date().

Remember
Date.now()

→ number (ms since 1970-01-01 UTC)
→ no Date instance required
→ call it again → a new (usually larger) value

Date.now()              → current epoch ms
new Date().getTime()    → same idea (needs an instance)
performance.now()       → elapsed ms since page load (browser)

Syntax

Call Date.now. Start with this line.

JavaScript
Date.now()
CallWhat it does
Date.now()Primary signature.
Date.now(...)Call with the arguments your case needs.

Built into JavaScript. Call Date.now(...) on the Date constructor — no import required.

Library declarations
JavaScript
Date.now()

Parameters

This method has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*The value returned by Date.now().

JavaScript Examples

Example 1 — Read the Current Timestamp

Call Date.now() and check that you get a large integer.

JavaScript
const ts = Date.now();

console.log(typeof ts);           // "number"
console.log(Number.isInteger(ts)); // true
console.log(ts > 1_000_000_000_000); // true (after year 2001)
Try It Yourself

How It Works

  1. Static call. Date.now() needs no instance.
  2. Type. The result is a number of milliseconds.
  3. Integer. Epoch timestamps are whole milliseconds.
  4. Size. Values after 2001 are greater than 1e12.

Example 2 — Date.now() vs getTime()

Both express epoch milliseconds; only one needs a Date object.

JavaScript
const a = Date.now();
const b = new Date().getTime();

console.log(typeof a);           // "number"
console.log(typeof b);           // "number"
console.log(Math.abs(a - b) < 5); // true — same moment window
Try It Yourself

How It Works

  1. Static path. Date.now() asks the clock directly.
  2. Instance path. new Date().getTime() builds a Date, then reads it.
  3. Nearly equal. Calls a few lines apart stay within a few ms.
  4. Prefer Date.now() when you only need the current timestamp.

Example 3 — Measure Elapsed Milliseconds

Match the MDN pattern: capture a start time, do work, subtract.

JavaScript
const start = Date.now();

let sum = 0;
for (let i = 0; i < 100000; i++) sum += i;

const elapsed = Date.now() - start;

console.log(elapsed >= 0);   // true
console.log(typeof elapsed); // "number"
Try It Yourself

How It Works

  1. Start mark. Store Date.now() before the work.
  2. Do work. Any code between the two calls counts.
  3. Subtract. Date.now() - start is elapsed milliseconds.
  4. Wall clock. For micro-benchmarks in browsers, prefer performance.now().

Browser & Runtime Support

Date.now() has been in the language since ES5 and is Baseline Widely available (MDN).

✓ Baseline · Widely available

Date.now()

Supported in every modern browser and Node.js. No polyfill needed for ordinary web apps.

99% Modern browser support
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.now() Excellent

Bottom line: Safe everywhere. Focus on units (ms vs seconds) and when to prefer performance.now() rather than feature detection.

Frequently Asked Questions

A number: milliseconds since January 1, 1970 00:00:00 UTC (the Unix epoch) at the moment you call it. It is not a clock component like 0–59.
No. Date.now() is a static method on the Date constructor. Call Date.now() directly.
Date.now() is static and returns the current epoch milliseconds. getTime() reads an existing Date. For “right now”, new Date().getTime() and Date.now() are equivalent.
Milliseconds. Use Math.floor(Date.now() / 1000) when you need whole Unix seconds.
Date.now() is wall-clock epoch time (can jump if the system clock changes). performance.now() is high-resolution elapsed time since page load and is better for micro-benchmarks in the browser.
Yes. To limit fingerprinting, some browsers round timestamps. The value is still an integer number of milliseconds (MDN).

Next: Date.parse()

Learn how to turn a date string into epoch milliseconds.

Date.parse() 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.

11 people found this page helpful