How to Convert from UTC to Local Time in Moment JS? Last Updated : 01 Aug, 2024 Comments Improve Suggest changes Like Article Like Report Moment.js is a powerful library for working with dates and times in JavaScript. One common requirement is to convert a date and time from Coordinated Universal Time (UTC) to the local time zone of the user's device. This is especially useful for applications that need to display times in the user's local context.To use the MomentJS library, we must ensure that we have installed the library. We can do so by using the following command.Installing Moment.js in Node.jsnpm i momentThese are the following approaches:Table of ContentUsing the .local() methodUsing the utcOffset() MethodUsing the local() methodIn this approach, we are using the local() method of Moment.js. This method converts the date and time from UTC to the local time zone. This method is simple and straightforward.Syntax:moment.utc().local();Example: Below example uses a local() method in momentJS to convert from UTC to local time. JavaScript const moment = require("moment"); let utcTime = moment.utc("2024-07-26T12:00:00Z"); let localTime = utcTime.local(); console.log( `Local time for 2024-07-26T12:00:00Z (UTC) is: ${localTime.format( "YYYY-MM-DD HH:mm:ss" )}` ); Output:Local time for 2024-07-26T12:00:00Z (UTC) is: 2024-07-26 17:30:00Using the utcOffset() MethodIn this approach we are using the utcOffset() method which allows us to set a specific UTC offset to convert the time. This method is useful if we need to convert the time to a different time zone, not just the local one.Syntax:moment.utc().utcOffset(offset);Example: Below example uses utcOffset() method in momentJS to convert from UTC to local time. JavaScript const moment = require("moment"); let utcTime = moment.utc("2024-07-26T12:00:00Z"); let offsetTime = utcTime.utcOffset(-240); console.log( `Time for 2024-07-26T12:00:00Z (UTC) with offset -240 is: ${offsetTime.format( "YYYY-MM-DD HH:mm:ss" )}` ); Output:Time for 2024-07-26T12:00:00Z (UTC) with offset -240 is: 2024-07-26 08:00:00 Comment More infoAdvertise with us Next Article How to Convert from UTC to Local Time in Moment JS? Y yuvrajghule281 Follow Improve Article Tags : JavaScript Web Technologies Moment.js Similar Reads How to convert MomentJS Date to Users Local Timezone? When we are working with dates, sometimes we need to display the time in the user's local timezone. For example, when we are building a global application where users are in different parts of the world. We are going to learn how to convert Moment.js date to users' local timezone. Below are the appr 2 min read 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 Calculate Local Time in Node.js ? Calculating local time in Node.js is a common requirement for many applications, especially those that operate across multiple time zones. Node.js, with its non-blocking, event-driven architecture, makes handling dates and times relatively straightforward. This article will guide you through differe 2 min read How to Remove Time From Date with Moment.js? Moment.js is a widely used JavaScript library for managing and manipulating dates and times. It simplifies complex date operations and makes it easier to work with dates in a consistent format. One common task is to extract just the date portion from a full timestamp, ignoring the time part. This is 2 min read How to use moment.js to change date format in jQuery ? Using Moment.js to change date format in jQuery involves importing the Moment.js library and utilizing its functions to parse, manipulate, and format dates. You can easily convert dates into various formats by calling moment(date).format(desiredFormat) to display the date in your preferred format.mo 2 min read Like