No Time to Read - Copy/Paste Solution

function getCurrentTimestamp () {


The UNIX timestamp is defined as the number of seconds since January 1, 1970 UTC. In JavaScript, in order to get the current timestamp, you can use

It's important to note that will return the number of milliseconds since January, 1 1970 UTC. If you need the number of seconds, you'll need to divide the result by 1000.

function getTimestampInSeconds () {
return Math.floor( / 1000)

The Date class is full of all sorts of handy methods. If you're doing anything with dates in JavaScript, you'll want to use it. You can find the complete API here.

Before you leave

I know, "another newsletter pitch" - but hear me out. Most JavaScript newsletters are terrible. When's the last time you actually looked forward to getting one? Even worse, when's the last time you actually read one rather than just skim it?

We wanted to change that, which is why we created Bytes. The goal was to create a JavaScript newsletter that was both educational and entertaining. 101,884 subscribers and an almost 50% weekly open rate later, it looks like we did it.

Delivered to 101,884 developers every Monday