Categories
JavaScript Answers

How to return the current timestamp with Moment.js?

Spread the love

Sometimes, we want to return the current timestamp with Moment.js.

In this article, we’ll look at how to return the current timestamp with Moment.js.

How to return the current timestamp with Moment.js?

To return the current timestamp with Moment.js, we can use the unix method.

For instance, we write

const currentDate = moment().unix();

to return the current UNIX timestamp.

Conclusion

To return the current timestamp with Moment.js, we can use the unix method.

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 *