Ask coding questions

← Back to all posts
timezone changed but offset stays at zero
ceilingrat

I want the date command to give me the correct localized timestamp, but it only gives me GMT/UTC time.

I've included a small script, date-test.sh, to demonstrate that changing the timezone only changes the label. The offset remains 0000.

(Clicking 'run' will trigger 'date-test.sh')

Alternatively to running the repl environment, you can watch this animation:
https://asciinema.org/a/jF07jYJWRVDNMXWaxF2o7HZGi

Voters
ceilingrat
Comments
hotnewtop
ceilingrat

I was able to figure it out with some help from this page:
https://www.cyberciti.biz/faq/howto-linux-set-time-zone-per-user-basis/

To summarize, the value I was passing with using the TZ environment variable was the issue.