Navigate back to the homepage

How to convert date to milliseconds in typescript?

Infinitbility
TypeScript
May 2nd, 2022 · 1 min read
keep affilitate

Hi Friends 👋,

Welcome to Infinitbility ❤️!

Today, we are going to learn How to convert date to milliseconds in typescript?, here we will use the date built-in method getTime() to get a date in milliseconds.

Intro to getTime()

The getTime() method returns the number of milliseconds since the ECMAScript epoch.

A number representing the milliseconds elapsed between 1 January 1970 00:00:00 UTC and the given date.

Code summary

Here, we will see what we are going to do:

  1. Get the current date and store variable
  2. Use getTime() method
  3. Print date converted milliseconds value

Code example

1// Get current date and store variable
2const date = new Date();
3
4// Use `getTime()` method
5const milliseconds = date.getTime();
6
7// Print date converted milliseconds value
8console.log(milliseconds);

Code output

When you run the above code, you will get the date convert in milliseconds example output. For now, let’s check the output.

TypeScript, convert date to iso string example
TypeScript, convert date to iso string example

All the best 👍.

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

melio affilitate

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

How to convert date to iso format in typescript?

TypeScript, convert date to iso string example.

May 1st, 2022 · 1 min read

How to add items to array in javascript?

Example of add items to array in javascript with step by step guide.

April 30th, 2022 · 1 min read
© 2020–2022 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]