Sometimes, we want to convert date to UTC using moment.js and JavaScript.
In this article, we’ll look at how to convert date to UTC using moment.js and JavaScript.
How to convert date to UTC using moment.js and JavaScript?
To convert date to UTC using moment.js and JavaScript, we can use the moment’s utc
method.
For instance, we write
const utcStart = new moment("2022-06-24T09:00", "YYYY-MM-DDTHH:mm").utc();
to create a moment object with the datetime with moment
.
Then we call utc
to return a moment object with the same date in UTC.
Conclusion
To convert date to UTC using moment.js and JavaScript, we can use the moment’s utc
method.