To convert a GMT (UTC) time to local time in JavaScript, you can use the “Date” object and the “toLocaleString()” method.
First, convert the GMT date string to a Date object using the “new Date()” constructor and then use the “toLocaleString()” method to convert it into the local time.
Example
// Create a GMT (UTC) date string
const gmtDateString = '2023-04-22T15:30:00Z';
// Convert the GMT date string to a Date object
const gmtDate = new Date(gmtDateString);
// The Date object will automatically be in the local time zone
console.log('Local Time:', gmtDate.toLocaleString());
Output
Local Time: 4/22/2023, 9:00:00 PM
In the above code example, we created a GMT (UTC) date string called “gmtDateString”.
In the next step, we created a Date object called gmtDate using the GMT date string.
Then, we used the “toLocaleString()” method to format the Date object as a string in the local time zone and logged the result to the console.
Remember that the system will determine the local time zone, so the output may vary depending on the user’s location and system settings.

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.