There are several ways to get the current time in JavaScript:

  • new Date() creates a Date object representing current date/time
  • new Date().valueOf() returns number of milliseconds since midnight 01 January, 1970 UTC
  • new Date().getTime() Functionally equivalent to new Date().valueOf()
  • Date.now() Functionally equivalent to the 2 methods above

As mentioned in the comments and MDN links, Date.now() is not supported in Internet Explorer 8. So if IE 8 compatibility is a concern you should use new Date().valueOf() at the cost of slightly diminished code readability.

Or if you want to use Date.now() but must be compatible with browsers which don't support it, you can place following code somewhere in your JavaScript files, which will add support for it.

if (!Date.now) {
    Date.now = function() {
        return new Date().getTime();
    }
}
Answer from Bohuslav Burghardt on Stack Overflow
🌐
W3Schools
w3schools.com › jsref › jsref_now.asp
JavaScript Date now() Method
Date.now() returns the number of milliseconds since January 1, 1970.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
When called as a constructor, returns a new Date object. When called as a function, returns a string representation of the current date and time. Date.now() Returns the numeric value corresponding to the current time—the number of milliseconds since January 1, 1970 00:00:00 UTC, with leap ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › Date
Date() constructor - JavaScript | MDN
When no parameters are provided, the newly-created Date object represents the current date and time as of the time of instantiation. The returned date's timestamp is the same as the number returned by Date.now().
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › difference-between-new-date-and-datenow-in-javascript
Difference Between new Date() and Date.now() in JavaScript - GeeksforGeeks
August 5, 2025 - Example: This example shows the use of new Date() constructor. ... The Date.now() method returns the numeric value corresponding to the current time—the number of the milliseconds elapsed since January 1, 1970, 00:00:00 UTC.
🌐
Sololearn
sololearn.com › en › Discuss › 2967337 › new-date-vs-datenow
new Date vs Date.now() | Sololearn: Learn to code for FREE!
• new Date() - creates a Date object representing the current date/time • Date.now() - returns the number of milliseconds since midnight 01 January, 1970 UTC As a matter of style, I found it clearer to use Date.now() in code that deals with ...
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Date and time
It is semantically equivalent to new Date().getTime(), but it doesn’t create an intermediate Date object. So it’s faster and doesn’t put pressure on garbage collection. It is used mostly for convenience or when performance matters, like in games in JavaScript or other specialized applications. ... let start = Date.now(); // milliseconds count from 1 Jan 1970 // do the job for (let i = 0; i < 100000; i++) { let doSomething = i * i * i; } let end = Date.now(); // done alert( `The loop took ${end - start} ms` ); // subtract numbers, not dates
Find elsewhere
🌐
W3Schools
w3schools.com › js › js_dates.asp
W3Schools.com
One day (24 hours) is 86 400 000 milliseconds. Now the time is: milliseconds past January 01, 1970 · new Date(milliseconds) creates a new date object as milliseconds plus zero time:
🌐
CalendarDate
calendardate.com › todays.htm
Today's Date
Details about today's date with count of days, weeks, and months, Sun and Moon cycles, Zodiac signs and holidays.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › now
Date.now() - JavaScript | MDN
The Date.now() static method returns the number of milliseconds elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC.
🌐
Day.js
day.js.org › docs › en › parse › now
Now · Day.js
Calling dayjs() without parameters returns a fresh Day.js object with the current date and time. var now = dayjs() This is essentially the same as calling dayjs(new Date()). Day.js treats dayjs(undefined) as dayjs() due to that function parameters default to undefined when not passed in.
🌐
Time and Date
timeanddate.com
Time and Date
Add or subtract days, months, or years to or from a specific date.
🌐
Educative
educative.io › answers › what-is-datenow-in-javascript
What is Date.now() in Javascript?
The Date.now() method returns a number that represents the milliseconds that have passed since the UNIX epoch up until now.
🌐
W3Schools
w3schools.com › jsref › jsref_date_new.asp
JavaScript new Date Method
new Date() constructor getDate() getDay() getFullYear() getHours() getMilliseconds() getMinutes() getMonth() getSeconds() getTime() getTimezoneOffset() getUTCDate() getUTCDay() getUTCFullYear() getUTCHours() getUTCMilliseconds() getUTCMinutes() getUTCMonth() getUTCSeconds() now() parse() prototype setDate() setFullYear() setHours() setMilliseconds() setMinutes() setMonth() setSeconds() setTime() setUTCDate() setUTCFullYear() setUTCHours() setUTCMilliseconds() setUTCMinutes() setUTCMonth() setUTCSeconds() toDateString() toISOString() toJSON() toLocaleDateString() toLocaleTimeString() toLocaleString() toString() toTimeString() toUTCString() UTC() valueOf() JS Function ·
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › system.datetime.now
DateTime.Now Property (System) | Microsoft Learn
The Now property returns a DateTime value that represents the current date and time on the local computer.
🌐
Moment.js
momentjs.com › docs
Moment.js | Docs
Get + Set Millisecond Second Minute Hour Date of Month Day of Week Day of Week (Locale Aware) ISO Day of Week Day of Year Week of Year Week of Year (ISO) Month Quarter Year Week Year Week Year (ISO) Weeks In Year Weeks In Year (ISO) Get Set Maximum Minimum · Manipulate Add Subtract Start of Time End of Time Maximum Minimum Local UTC UTC offset Time zone Offset · Display Format Time from now Time from X Time to now Time to X Calendar Time Difference Unix Timestamp (milliseconds) Unix Timestamp (seconds) Days in Month As Javascript Date As Array As JSON As ISO 8601 String As Object As String Inspect
🌐
RapidTables
rapidtables.com › tools › todays-date.html
Today's Date | Current date now 📅
Home›Tools›Current date now · Today's current date and time with time zone and date picker: This page includes the following information: Today's date: day of week, month, day, year. Current time: hours, minutes, seconds. Time zone with location and GMT offset.
🌐
Epoch Converter
epochconverter.com › daynumbers
What's the Current Day Number?
This page uses the ISO-8601 ordinal date format. There is also another less-used format: the 'ISO day of year' numbers, this is a number between 1 and 371, day 1 of the year is Monday of the first ISO week (where the first Thursday of the new year is in week 1). Lists of day numbers by year: 2025 - 2026 - 2027 - 2028 ... ... #include <iostream> #include <chrono> int main() { auto now = std::chrono::system_clock::now(); std::chrono::year_month_day current_date{std::chrono::floor<std::chrono::days>(now)}; std::chrono::weekday today{std::chrono::sys_days{current_date}}; // ISO-8601 defines Monday as 1 and Sunday as 7.