How to get JavaScript Date in UTC using MomentJS? Last Updated : 30 Aug, 2024 Comments Improve Suggest changes Like Article Like Report When working with dates and times in JavaScript, especially in applications that deal with users across different time zones, it is often necessary to work with dates in UTC (Coordinated Universal Time). Below are the approaches to get a date in UTC using Moment.js:Table of ContentUsing moment().utc() to get the current date and time in UTCCreating a specific date in UTC using moment.utc()Converting an existing Moment object to UTC using moment.local().utc()Using moment().utc() to get the current date and time in UTCThis approach is used to get the current date and time in UTC. The moment().utc() method returns a Moment object representing the current date and time in UTC.Example: In this example we are using the moment().utc() method to get the current date and time in UTC. JavaScript const moment = require('moment'); const utcDate = moment().utc(); console.log(utcDate.format()); Output:2024-08-28T11:09:30ZCreating a specific date in UTC using moment.utc()When we need to create a date in UTC we can use the moment.utc() method and pass the specific date and time as arguments. This method is useful when working with historical dates or scheduled events.Example: In below example we are using creating the specific date in UTC. JavaScript const moment = require('moment'); const utcSpecificDate = moment.utc('2024-08-28T12:34:56'); console.log(utcSpecificDate.format()); Output:2024-08-28T12:34:56ZConverting an existing Moment object to UTC using moment.local().utc()When we have a local date and time that we need to convert to UTC we can first create a Moment object in local time and then use the .utc() method to convert it to UTC.Example: In below example we are converting the the local time to the UTC. JavaScript const moment = require('moment'); const localDate = moment('2024-08-28T12:34:56'); const utcDate = localDate.utc(); console.log(utcDate.format()); Output:2024-08-28T12:34:56Z Comment More infoAdvertise with us Next Article How to get JavaScript Date in UTC using MomentJS? Y yuvrajghule281 Follow Improve Article Tags : JavaScript Web Technologies Moment.js Similar Reads How to convert UTC date time into local date time using JavaScript ? Given an UTC date and the task is to convert UTC date time into local date-time using JavaScript toLocaleString() function. Syntax: var theDate = new Date(Date.parse('DATE_IN_UTC')) theDate.toLocaleString() Example 1: This example converts UTC date time into local date time using JavaScript. html 1 min read How to Get Last Day of Previous Month From Date in Moment.JS? To get the last day of the previous month from a given date in Moment.js, you need to adjust the date to the start of the current month and then subtract one day. This approach allows you to accurately find the final day of the previous month regardless of varying month lengths.Installing Moment.js 2 min read How To Set Time With Date in Moment.js? Moment.js is a powerful JavaScript library that makes it easy to work with dates and times. Sometimes, we want to set a specific time to an already existing date. For example- we have a date like "2024-08-15" and we want to set the time to "9:00 AM". Moment.js provides simple ways to do this. In thi 2 min read JavaScript Date UTC() Method In JavaScript, the Date.UTC() method is used to create a date object representing a specified date and time in UTC (Coordinated Universal Time). It accepts the year, month, day, hour, minute, second, and millisecond components of the date and returns the number of milliseconds since January 1, 1970, 4 min read How to Convert Date to Another Timezone in JavaScript? Converting a date to another timezone in JavaScript means adjusting the local date and time to match the time in a different timezone. This ensures that the displayed time aligns with the selected timezone, often using built-in methods or external libraries.1. Using Intl.DateTimeFormat() and format( 2 min read Like