Try Date.now().

The skipping is most likely due to garbage collection. Typically garbage collection can be avoided by reusing variables as much as possible, but I can't say specifically what methods you can use to reduce garbage collection pauses.

Answer from Joeri Sebrechts on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › now
Date.now() - JavaScript - MDN Web Docs - Mozilla
You can use Date.now() to get the current time in milliseconds, then subtract a previous time to find out how much time elapsed between the two calls.
🌐
W3Schools
w3schools.com › jsref › jsref_getmilliseconds.asp
JavaScript Date getMilliseconds() Method
getMilliseconds() returns the milliseconds (0 to 999) of a date. Date.getMilliseconds() getMilliseconds() is an ECMAScript1 (JavaScript 1997) feature. It is supported in all browsers: Add zeros and colons to display the time: function addZero(x, ...
🌐
GeeksforGeeks
geeksforgeeks.org › html › how-to-get-milliseconds-in-javascript
How to Get Milliseconds in JavaScript? - GeeksforGeeks
August 5, 2025 - You can quickly get the current time in milliseconds using the Date class's now() method. It's a direct way to get accurate time information whenever you require it. Example: To illustrate how to utilize JavaScript's Date.now() method to retrieve ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getMilliseconds
Date.prototype.getMilliseconds() - JavaScript - MDN - Mozilla
July 10, 2025 - const moonLanding = new Date("July 20, 69 00:20:18"); moonLanding.setMilliseconds(123); console.log(moonLanding.getMilliseconds()); // Expected output: 123 ... An integer, between 0 and 999, representing the milliseconds for the given date according to local time.
🌐
HTML Code Generator
html-code-generator.com › javascript › live-date-time-with-milliseconds
Live Date And Time With Milliseconds (AM/PM)
... const liveTimeWithMillisecond ... seconds = now.getSeconds().toString().padStart(2, '0'); const milliseconds = now.getMilliseconds().toString().padStart(3, '0'); // 12-hour clock with AM/PM....
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getTime
Date.prototype.getTime() - JavaScript - MDN Web Docs
The getTime() method of Date instances returns the number of milliseconds for this date since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC. const moonLanding = new Date("July 20, 69 20:17:40 GMT+00:00"); // Milliseconds since Jan 1, 1970, 00:00:00.000 ...
🌐
OneCompiler
onecompiler.com › questions › 3stj4vak6 › how-to-get-current-time-in-milliseconds-in-javascript
How to get current time in milliseconds in Javascript - Questions - OneCompiler
Following is the Javascript code to get current time in milliseconds · var millies = Date.now(); Some other ways of getting current time in milliseconds ·
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getUTCMilliseconds
Date.prototype.getUTCMilliseconds() - JavaScript | MDN
July 10, 2025 - const exampleDate = new Date("2018-01-02T03:04:05.678Z"); // 2 January 2018, 03:04:05.678 (UTC) console.log(exampleDate.getUTCMilliseconds()); // Expected output: 678 ... An integer, between 0 and 999, representing the milliseconds for the given date according to universal time.
Find elsewhere
🌐
Reactgo
reactgo.com › home › get the current time in milliseconds using javascript
Get the current time in milliseconds using JavaScript | Reactgo
June 14, 2023 - In JavaScript, we can get the current by calling a getTime() on the new Date() constructor. ... To get the current time in milliseconds, divide the current time with 1000, because 1second = 1000 milliseconds.
🌐
CoreUI
coreui.io › answers › how-to-get-current-timestamp-in-javascript
How to get current timestamp in JavaScript · CoreUI
September 30, 2025 - Use Date.now() to get the current timestamp in JavaScript - the fastest and most reliable method for milliseconds since Unix epoch.
🌐
TutorialsPoint
tutorialspoint.com › javascript › date_getmilliseconds.htm
JavaScript Date getMilliseconds() Method
In the following example, we are demonstrating the basic usage of JavaScript Date getMilliseconds() method − · <html> <body> <script> const currentDate = new Date(); const milliseconds = currentDate.getMilliseconds(); document.write(mill...
🌐
ui.dev
ui.dev › get-current-timestamp-javascript
How to get the current timestamp in JavaScript
In JavaScript, in order to get the current timestamp, you can use Date.now(). It's important to note that Date.now() will return the number of milliseconds since January, 1 1970 UTC.
🌐
TypeScript TV
typescript.tv › hands-on › convert-to-milliseconds
Convert to milliseconds
Let's say you live in Berlin (Germany), and you want to represent June, 26th of 2019 at midnight in milliseconds with Central European Summer Time (GMT+2). Using Moment.js v2.24 you have at least the following possibilities to do that: ... import moment from 'moment'; const unixTimestamp = moment('2019-06-26T00:00:00.000+02:00').valueOf(); console.log('unixTimestamp', unixTimestamp); // 1561500000000 ... import moment from 'moment'; const utcOffsetInMinutes = new Date().getTimezoneOffset(); // -120 (2 hours) const utcOffsetInMillis = utcOffsetInMinutes * 60000; const unixTimestamp = moment('2019-06-26T00:00:00.000Z').valueOf() + utcOffsetInMillis; console.log('unixTimestamp', unixTimestamp); // 1561500000000