Categories
JavaScript Answers

How to extract time from moment.js object with JavaScript?

Spread the love

Sometimes, we want to extract time from moment.js object with JavaScript.

In this article, we’ll look at how to extract time from moment.js object with JavaScript.

How to extract time from moment.js object with JavaScript?

To extract time from moment.js object with JavaScript, we can use the format method.

For instance, we write

const time = moment("2022-01-16T12:00:00").format("hh:mm:ss a");

to call format with "hh:mm:ss a" to return the time string of the date time in hours:minutes:seconds AM/PM format.

Conclusion

To extract time from moment.js object with JavaScript, we can use the format method.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.