const timestamp = new Date().getTime()

console.log(timestamp)

For more information, see @James McMahon's answer.

Answer from ExpExc on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › UTC
Date.UTC() - JavaScript | MDN
const utcDate1 = new Date(Date.UTC(96, 1, 2, 3, 4, 5)); const utcDate2 = new Date(Date.UTC(0, 0, 0, 0, 0, 0)); console.log(utcDate1.toUTCString()); // Expected output: "Fri, 02 Feb 1996 03:04:05 GMT" console.log(utcDate2.toUTCString()); // Expected output: "Sun, 31 Dec 1899 00:00:00 GMT"
🌐
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_getutcdate.asp
JavaScript Date getUTCDate() 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
🌐
Futurestud.io
futurestud.io › tutorials › convert-a-date-to-utc-in-javascript-or-node-js
Convert a Date to UTC in JavaScript or Node.js
Here’s the sample code using the getUTC<unit> methods to compose a date string without the T and Z characters. const date = new Date() const year = date.getUTCFullYear() const month = (date.getUTCMonth() + 1).toString().padStart(2, '0') const day = date.getUTCDate().toString().padStart(2, ...
🌐
Day.js
day.js.org › docs › en › plugin › utc
UTC · Day.js
var utc = require("dayjs/plugin/utc"); // import utc from 'dayjs/plugin/utc' // ES 2015 dayjs.extend(utc); // default local time dayjs().format(); //2019-03-06T17:11:55+08:00 // UTC mode dayjs.utc().format(); // 2019-03-06T09:11:55Z // convert local time to UTC time dayjs().utc().format(); // 2019-03-06T09:11:55Z // While in UTC mode, all display methods will display in UTC time instead of local time. // And all getters and setters will internally use the Date#getUTC* and Date#setUTC* methods instead of the Date#get* and Date#set* methods.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toUTCString
Date.prototype.toUTCString() - JavaScript | MDN
The toUTCString() method of Date instances returns a string representing this date in the RFC 7231 format, with negative years allowed. The timezone is always UTC. toGMTString() is an alias of this method.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
Note: While the time value at the heart of a Date object is UTC, the basic methods to fetch the date and time or its components all work in the local (i.e., host system) time zone and offset. The maximum timestamp representable by a Date object is slightly smaller than the maximum safe integer (Number.MAX_SAFE_INTEGER, which is 9,007,199,254,740,991).
🌐
W3Schools
w3schools.com › jsref › jsref_utc.asp
JavaScript Date UTC() Method
let d = new Date(Date.UTC(2020, 02, 30)); Try it Yourself » ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want ...
Find elsewhere
🌐
Attacomsian
attacomsian.com › blog › javascript-get-current-date-time-in-utc
How to get current date and time in UTC using JavaScript
September 12, 2022 - The toUTCString() method returns a date object as a string using the UTC time zone. Alternatively, you could also use the toISOString() method to get the date string in ISO 8601 format of YYYY-MM-DDTHH:mm:ss.sssZ: const isoStr = new ...
🌐
Jaketrent
jaketrent.com › post › javascript-dates-utc
JavaScript Dates and UTC
If you want to specify the parts of the date separately but get a UTC date, see the fromLocalToUtc implementation below. If you want to specify the timezone using an IANA Timezone ID, see the article on setting timezones on JavaScript dates.
🌐
SheCodes
shecodes.io › athena › 127613-how-to-update-time-in-milliseconds-in-real-time-and-in-utc-using-javascript
[JavaScript] - How to update time in milliseconds in real time and in UTC using JavaScript
International Women’s Week Sale 🎉 30% off on all coding workshops ending on March 9th Ending in 1 day Get Deal Get This Deal NOW ... Learn how to use JavaScript to update the time in milliseconds in real time and in UTC using the setInterval function.
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-get-current-date-and-time-in-utc
Get the current Date and Time in UTC/GMT using JavaScript | bobbyhadz
The difference between them is that GMT is a time zone, whereas UTC is a time standard and is the basis for time zones worldwide. In the first example, we used the Date.UTC method, which treats the passed-in parameters as UTC.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getUTCDate
Date.prototype.getUTCDate() - JavaScript | MDN
const date1 = new Date("August 19, 1975 23:15:30 GMT+11:00"); const date2 = new Date("August 19, 1975 23:15:30 GMT-11:00"); console.log(date1.getUTCDate()); // Expected output: 19 console.log(date2.getUTCDate()); // Expected output: 20
🌐
Moment.js
momentjs.com › docs
Moment.js | Docs
Note: Despite Unix timestamps being UTC-based, this function creates a moment object in local mode. If you need UTC, then subsequently call .utc(), as in: ... You can create a Moment with a pre-existing native Javascript Date object.
🌐
CoreUI
coreui.io › answers › how-to-get-the-utc-date-in-javascript
How to get the UTC date in JavaScript · CoreUI
October 27, 2025 - Use UTC methods to get timezone-independent date components. const now = new Date() const utcYear = now.getUTCFullYear() const utcMonth = now.getUTCMonth() const utcDate = now.getUTCDate()
🌐
GeeksforGeeks
geeksforgeeks.org › javascript-date-utc-method
JavaScript Date UTC() Method | GeeksforGeeks
July 12, 2024 - This method doesn’t require ...ParametersTh ... The JavaScript Date parse() method parses a date string and returns the number of milliseconds between the date string and midnight of January 1, 1970, UTC....
🌐
Medium
frontendinterviewquestions.medium.com › how-to-get-current-time-in-javascript-a7cdb04cd220
How to Get Current Time in JavaScript | by Pravin M | Medium
June 19, 2024 - // Create a new Date object let currentDateUTC = new Date(); // Get current UTC time let currentUTCTime = currentDateUTC.toUTCString(); console.log("Current UTC time is:", currentUTCTime);
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-convert-a-javascript-date-to-utc
How to convert a JavaScript date to UTC? | GeeksforGeeks
December 13, 2023 - Javascript date can be converted to UTC by using functions present in the Javascript Date object. The toUTCString() method is used to convert a Date object into a string, according to universal time.