This site is in development
How to convert a UTC time to a local time in JavaScript

Home > Blogs

How to convert a UTC time to a local time in JavaScript

April 11, 2023

Let’s say you have this UTC time string: "2023-03-13T03:31:01Z"

You can do it like this:

javascript

const utcDate = new Date("2023-03-13T03:31:01Z"); const localDate = new Date(utcDate.getTime() - utcDate.getTimezoneOffset() * 60000);

Explanation here:

  1. ok

  • one lorem ipsum dolor
  • two
  1. se