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.