Last Updated : 11 Jul, 2025
The Date.now() method in JavaScript returns the current timestamp in milliseconds since January 1, 1970. This method doesn’t require creating a new date object, making it one of the fastest and most efficient ways to capture the current time in your code.
Syntaxlet curr_date = Date.now();Parameters
Example 1: The below example of the Date now() method.
JavaScript
// Use of method Date.now()
let A = Date.now();
// Printing the number of millisecond elapsed
console.log("The time elapsed in millisecond is: " + A);
The time elapsed in millisecond is: 1720904397838Explanation:
The code snippet utilizes `Date.now()` to retrieve the current timestamp in milliseconds since the Unix epoch. It stores this value in variable `A` and prints it, indicating the elapsed milliseconds since the epoch.
Example 2: This example of getting the current date using the Date.now() method.
JavaScript
// Use of Date.now() method
let d = Date(Date.now());
// Converting the number of millisecond in date string
a = d.toString()
// Printing the current date
console.log("The current date is: " + a)
The current date is: Sat Jul 13 2024 20:59:57 GMT+0000 (Coordinated Universal Time)Explanation:
The code snippet generates a new Date object using the current timestamp from Date.now(). It then converts this date object to a string format using .toString() and logs it, displaying the current date and time.
We have a complete list of Javascript Date Objects, to check those please go through this Javascript Date Object Complete reference article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4