# How to get a timestamp with JavaScript

*Photo by [insung yoon](https://unsplash.com/@insungyoon?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText)*

A timestamp is a numerical value that represents the amount of time that has passed since the Unix epoch (1st Jan 1970) and you get the number of ​milliseconds ​since then with the `Date.now()` ​function in JavaScript.

So you might want to divide this by 1000 and round it to get the number of seconds which is more commonly used for timestamps.

```javascript
Date​.​now​(); // Milliseconds
Math​.​round​(​Date​.​now​()​ ​/​ ​1000​); // Seconds
```

[Watch the tutorial for more details.](https://www.youtube.com/watch?v=iij3lA6RMpQ&list=PLpc_YvcwbxaRSFpQQSNBBN3WxhFV7OaI_&index=30)

Follow me on Twitter ([@codebubb](https://twitter.com/codebubb)) for more tutorials.
