They both serve different purposes.

performance.now() is relative to page load and more precise in orders of magnitude. Use cases include benchmarking and other cases where a high-resolution time is required such as media (gaming, audio, video, etc.)

It should be noted that performance.now() is available in IE10 or later browsers. See caniuse page.

Date.now() is relative to the Unix epoch (1970-01-01T00:00:00Z) and dependent on system clock. Use cases include same old date manipulation ever since the beginning of JavaScript.

See When milliseconds are not enough: performance.now and now method (Internet Explorer) - MSDN for more information.

The official W3C spec can be found here: High Resolution Time API

Answer from rink.attendant.6 on Stack Overflow
๐ŸŒ
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.
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ jsref_now.asp
JavaScript Date now() Method
Date.now() returns the number of milliseconds since January 1, 1970.
Discussions

javascript - performance.now() vs Date.now() - Stack Overflow
Date.now() is relative to the Unix epoch (1970-01-01T00:00:00Z) and dependent on system clock. Use cases include same old date manipulation ever since the beginning of JavaScript. More on stackoverflow.com
๐ŸŒ stackoverflow.com
Getting current date and time in JavaScript - Stack Overflow
Instead of those monstrous functions, we now can use moment.js to get the current date, which actually makes it very easy. All that has to be done is including moment.js in our project and get a well formated date, for example, by: ... I think that makes it way easier to handle dates in javascript. More on stackoverflow.com
๐ŸŒ stackoverflow.com
javascript - date = new Date(); date.valueOf() vs Date.now() - Stack Overflow
Recently I changed to Date.now() because it is more efficient or will become one day more efficient. Technically the OS reports the date time as a primitive, and by calling new Date() the JavaScript engine must create a object with prototypes (which is passed by reference, and must be garbage ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
JavaScript Date(Date)
Your code breaks if it's the first day of the month. And yeah, the built-in JavaScript date type is pretty garbage. I recommend using moment.js instead. More on reddit.com
๐ŸŒ r/programminghorror
25
48
August 8, 2017
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Date
Date - JavaScript | MDN
Due to the differing lengths of ... a number of issues, and should be thoroughly researched before being attempted. ... // Using Date objects const start = Date.now(); // The event to time goes here: doSomethingForALongTime(); const end = Date.now(); const elapsed = end - start; ...
๐ŸŒ
Toptal
toptal.com โ€บ developers โ€บ software โ€บ definitive-guide-to-datetime-manipulation
How to get the Timestamp And Date in Javascript: JS DateTime | Toptalยฎ
December 2, 2020 - This makes JavaScript date-from-timestamp and JavaScript timestamp-to-date conversion straightforward, provided the UTC time zone is used. If you donโ€™t intend to support <IE8, you can use Date.now() to directly get the time stamp without having to create a new Date object.
๐ŸŒ
Capacitor
capacitorjs.com
Capacitor by Ionic - Cross-platform apps with web technology
Capacitor is an open source native runtime for building Web Native apps. Create cross-platform iOS, Android, and Progressive Web Apps with JavaScript, HTML, and CSS.
๐ŸŒ
npm
npmjs.com โ€บ package โ€บ date-fns
date-fns - npm
Modern JavaScript date utility library. Latest version: 4.1.0, last published: a year ago. Start using date-fns in your project by running `npm i date-fns`. There are 24815 other projects in the npm registry using date-fns.
      ยป npm install date-fns
    
Published ย  Sep 17, 2024
Version ย  4.1.0
Find elsewhere
๐ŸŒ
CodeToFun
codetofun.com โ€บ js โ€บ date-now
JavaScript Date now() Method | CodeToFun
November 21, 2024 - In this guide, we'll explore the now() method, understand its syntax, and examine how to effectively use it in your JavaScript applications. The now() method of the Date object returns the current timestamp in milliseconds.
๐ŸŒ
Moment.js
momentjs.com
Moment.js | Home
Moment.js is freely distributable under the terms of the MIT license
๐ŸŒ
Edgecompute
js-compute-reference-docs.edgecompute.app โ€บ date() โ€บ date.now()
Date.now() | @fastly/js-compute
The static Date.now() method returns the number of milliseconds elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ javascript-date-now-method
JavaScript Date now() Method - GeeksforGeeks
July 11, 2025 - The Date.now() method in JavaScript returns the current timestamp in milliseconds since January 1, 1970.
๐ŸŒ
Nikita Hlopov
nikitahl.com โ€บ get-the-current-date-in-javascript
How to get the current date in JavaScript (Time, Day, Month, Year)
To get the current date in JavaScript youโ€™ll only need the Vanilla JavaScript Date API. All the information about the current date can be accessed in one lin...
๐ŸŒ
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 - 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.
๐ŸŒ
Bugfender
bugfender.com โ€บ blog โ€บ javascript-date-and-time
The Definitive Guide to JavaScript Date and Time | Bugfender
February 18, 2025 - The Date.now() static method returns the current timestamp in milliseconds.
Top answer
1 of 16
789

.getMonth() returns a zero-based number so to get the correct month you need to add 1, so calling .getMonth() in may will return 4 and not 5.

So in your code we can use currentdate.getMonth()+1 to output the correct value. In addition:

  • .getDate() returns the day of the month <- this is the one you want
  • .getDay() is a separate method of the Date object which will return an integer representing the current day of the week (0-6) 0 == Sunday etc

so your code should look like this:

var currentdate = new Date(); 
var datetime = "Last Sync: " + currentdate.getDate() + "/"
                + (currentdate.getMonth()+1)  + "/" 
                + currentdate.getFullYear() + " @ "  
                + currentdate.getHours() + ":"  
                + currentdate.getMinutes() + ":" 
                + currentdate.getSeconds();

JavaScript Date instances inherit from Date.prototype. You can modify the constructor's prototype object to affect properties and methods inherited by JavaScript Date instances

You can make use of the Date prototype object to create a new method which will return today's date and time. These new methods or properties will be inherited by all instances of the Date object thus making it especially useful if you need to re-use this functionality.

// For todays date;
Date.prototype.today = function () { 
    return ((this.getDate() < 10)?"0":"") + this.getDate() +"/"+(((this.getMonth()+1) < 10)?"0":"") + (this.getMonth()+1) +"/"+ this.getFullYear();
}

// For the time now
Date.prototype.timeNow = function () {
     return ((this.getHours() < 10)?"0":"") + this.getHours() +":"+ ((this.getMinutes() < 10)?"0":"") + this.getMinutes() +":"+ ((this.getSeconds() < 10)?"0":"") + this.getSeconds();
}

You can then simply retrieve the date and time by doing the following:

var newDate = new Date();
var datetime = "LastSync: " + newDate.today() + " @ " + newDate.timeNow();

Or call the method inline so it would simply be -

var datetime = "LastSync: " + new Date().today() + " @ " + new Date().timeNow();
2 of 16
548

To get time and date you should use

    new Date().toLocaleString();

>> "09/08/2014, 2:35:56 AM"

To get only the date you should use

    new Date().toLocaleDateString();

>> "09/08/2014"

To get only the time you should use

    new Date().toLocaleTimeString();

>> "2:35:56 AM"

Or if you just want the time in the format hh:mm without AM/PM for US English

    new Date().toLocaleTimeString('en-US', { hour12: false, 
                                             hour: "numeric", 
                                             minute: "numeric"});
>> "02:35"

or for British English

    new Date().toLocaleTimeString('en-GB', { hour: "numeric", 
                                             minute: "numeric"});

>> "02:35"

Read more here.

๐ŸŒ
Js
flatpickr.js.org โ€บ examples
Examples - flatpickr
The selected date will get parsed from the inputโ€™s value or the defaultDate option.
๐ŸŒ
UltaHost
ultahost.com โ€บ knowledge-base โ€บ get-current-date-time-javascript
How to Use JavaScript to Get the Current Date and Time | Ultahost Knowledge Base
March 7, 2025 - Learn how to use JavaScript to get the current date and time with code examples. Perfect for beginners and developers looking to display data.
๐ŸŒ
Nipr
hub.app.nipr.com โ€บ my-nipr โ€บ frontend โ€บ identify-licensee
LicenseHub
1100 Walnut Street, Suite 1500 Kansas City, MO 64106 ยท Need Assistance? Call (855) 674-6477