Default timezone is UTC. But I want to change it to GMT+2. I tried as below.
alter database governance set timezone = 'GMT+2';
But it does't work.
How can I manage it?
postgresql version is 9.5. And it run on Docker.
Thanks!
For those who uses TZ and nothing happens
the reason for me was that for the first time when container starts it stores TZ variable in PG config in mapped volume. and after changing docker compose file to another TZ value it stays the same and looks like it doesn't work. you should remove db first and then restart docker-compose
You should set timezone in your docker compose file (TZ
and PGTZ
are required):
postgres:
image: postgres
environment:
TZ: 'GMT+2'
PGTZ: 'GMT+2'
Reference: https://github.com/docker-library/postgres/issues/137#issuecomment-217064811
To change timezone of you image try this:
docker run -it -e "TZ=GMT+2" postgres:alpine
docker-compose.yml
postgres:
image: postgres:alpine
environment:
- TZ=GMT+2
You have to specify the timezone in the docker-compose.yml
file in this format:
postgres:
image: postgres:alpine
environment:
TZ: "Europe/Madrid"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With