Languages
[Edit]
EN

JavaScript - get UNIX timestamp in milliseconds

6 points
Created by:
Paris-Bateman
504

In this short article, we would like to show how to get unix timstamp in milliseconds in JavaScript.

Note: as unix timestamp in this article we understans bash date +%s%3N command result.

Quick solution:

// ONLINE-RUNNER:browser;

const now = Date.now();

console.log(now);  // 1639930461139

 

Reusable source code

// ONLINE-RUNNER:browser;

const getTimestamp = () => {
    return Date.now();
};


// Usage example:

const now = getTimestamp();

console.log(now);  // 1639930461139

 

See also

  1. JavaScript - get UNIX timestamp in seconds

  2. Linux / Bash - print current Unix time in milliseconds

  3. Linux / Bash - print current Unix time in seconds

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join