Categories
JavaScript Answers

How to set the default time zone in Node.js?

Spread the love

Sometimes, we want to set the default time zone in Node.js.

In this article, we’ll look at how to set the default time zone in Node.js.

How to set the default time zone in Node.js?

To set the default time zone in Node.js, we can set the TZ environment variable.

For instance, we write

process.env.TZ = 'Europe/Amsterdam'

to set TZ to the 'Europe/Amsterdam' time zone.

Now all local times are returned in the Europe/Amsterdam time zone.

Conclusion

To set the default time zone in Node.js, we can set the TZ environment variable.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *