# How to get a UTC timestamp in JavaScript

By Atta Ur Rehman Shah (https://attacomsian.com/about). Published Sep 11, 2022. Topics: JavaScript.
Canonical URL: https://attacomsian.com/blog/javascript-get-utc-timestamp

> Learn how to use the getTime() method of the date object to get a UTC timestamp in JavaScript.

To get a UTC timestamp in JavaScript:

1. Use the `getTime()` method of the `Date` object, e.g. `new Date().getTime()`.
2. The `getTime()` method returns the number of milliseconds since the [Unix Epoch](https://attacomsian.com/blog/unix-timestamp-javacript).

```javascript
const timestamp = new Date().getTime()

console.log(timestamp) // 1662916646151
```

The `getTime()` method returns the number of milliseconds elapsed between January 1st, 1970, at 00:00:00 UTC and the specific date.
