Date.now
Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC
Syntax
Date.now()Return Value
A number representing milliseconds since the Unix epoch
Examples
const timestamp = Date.now();
console.log(timestamp); // e.g. 1709251200000const start = Date.now();
// ... some operation ...
const elapsed = Date.now() - start;
console.log(`Took ${elapsed}ms`);const id = `item_${Date.now()}`;
console.log(id); // 'item_1709251200000'Understanding Date.now
The Date.now method in JavaScript returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC. It belongs to the Date object and is one of the most widely used methods for working with date values in modern JavaScript and TypeScript applications.
The method signature is Date.now(). When called, it returns a number representing milliseconds since the unix epoch. Understanding when and how to use now() helps you write more expressive, readable code.
Common use cases for Date.now include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like date-gettime, date-parse, date-toisostring, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Date.now is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
Date.prototype.getTimeReturns the number of milliseconds since January 1, 1970 00:00:00 UTC for the given date
Date.parseParses a string representation of a date, and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC
Date.prototype.toISOStringReturns a string in simplified extended ISO format (ISO 8601), which is always 24 or 27 characters long
More Date Methods
Other methods in the Date object
Related Tools
More Date Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.