Skip to content
Advertisement

How to convert Moment.js moment to unix timestamp

I see a lot in the Moment.js documentation about getting a Moment from a Unix timestamp. However, I am trying to convert a Moment to a Unix timestamp, and I am not sure how to do that. This is how my moment looks:

const myMomentObject = moment(str_time, ‘YYYY-MM-DD’);

And I need to convert it to a Unix timestamp.

Advertisement

Answer

Unix timestamp can be obtaineded with or without the moment library.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement