Convert UTC to local timezone – Node JS

In this tutorial, we will teach you, how you can convert UTC time to your local timezone in Node JS.

Following code will first get the current datetime in UTC, then convert it to user local timezone.

Note: You do not need to provide the timeZone from client side. Node JS will automatically detect the timeZone from incoming request and convert it accordingly.

let date = new Date()

date = new Date(date + " UTC")
date = date.toUTCString()

result.send(date + "")

Most important line here is:

date = new Date(date + " UTC")

If you do not write this line, then you will see the datetime in UTC.

Check this tutorial if you want to convert UTC to local timezone in Python.