Nodejs does not respect the OS daylight saving schedule

Asked

Viewed 1,077 times

1

I set my Timezone in the nodejs for America/Sao_paulo. But it does not respect the tables of the operating system.

I use Ubuntu 18.04 LTS + Nodejs V10. The method getTimezoneOffset of Date me returns offset 120 (-2) instead of 180 (-3). How can I fix the problem and do the method getTimeZoneOffset respect the S.O table? Or how can I be setting Timezone manually until I solve the problem.

Example teste.js:

process.env.TZ = 'America/Sao_Paulo';
console.log(new Date().getTimezoneOffset()); // retorna 120 não 180

Node: V10.16.0

1 answer

2

  • if you want to increment, I put the following code to temporarily resolve (first line of entrypoint index.js of my project): process.env.TZ = 'America/Fortaleza';

  • Ai is a lot of gambiarra kkkk. If it were GMT-3 still goes.... GMT-3 at least is deterministic (soon more deleting the comment)

  • rss. So I did not find any way to put the GMT-3 in a generic way kkkk also not liked much, but at the moment it is like this until find another solution (then delete also comment kkk)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.