Categories
JavaScript Answers

How to get JavaScript Date in UTC with Moment.js?

Spread the love

To get JavaScript Date in UTC with Moment.js, we use the date getTime method.

For instance, we write

const t = new Date().getTime();

to create a new date with the current date and time with the Date constructor.

Then we call getTime to return its timestamp in milliseconds.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *