JS Date () returns the correct time zone but the wrong date

I experience strange behavior when trying to get the current date using Date () in javascript. First, I set the time zone for Cuba to

sudo ln -sf /usr/share/zoneinfo/Cuba /etc/localtime 

and ran Date() in another console with node.js. That was the result -

 > Date() 'Thu Oct 31 2013 06:28:25 GMT+1100 (CDT)' 

When changing the time zone

 sudo ln -sf /usr/share/zoneinfo/Asia/Vladivostok /etc/localtime 

and run Date() again, this is the output -

 > Date() 'Thu Oct 31 2013 06:28:31 GMT+1100 (VLAT)' 

Can someone explain why this is happening and how can I get time based timezone?

+6
source share
1 answer

Some OS and node conflicting with the time clock show that although node correctly selects the time zone changes during its launch, it does not update the offset , which is why both dates show GMT+1100 .

If you restart node, you will find that the offset and time zone are correct. I suspect that it is deliberate to avoid unexpected time changes during the run, but cannot find anything with this as a result of a Google search.

+2
source

Source: https://habr.com/ru/post/957071/


All Articles