Languages
[Edit]
EN

TypeScript - get current time in milliseconds

0 points
Created by:
Vanessa-Drake
718

In this article, we would like to show you how to get the current time in milliseconds in TypeScript.

Quick solution:

const time: number = Date.now();

console.log(time); // Example output: 1647958987232

or: 

const getCurrentTime = (): number => {
  const date = new Date();
  return date.getTime();
};


// Usage example:

const time: number = getCurrentTime();

console.log(time); // Example output: 1647959027055

The above solutions return the current time in milliseconds since Unix Epoch (January 1, 1970). 

Alternative titles

  1. TypeScript - todays' time in milliseconds
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