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!
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!
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
TZ
is for GNU/Linux and PGTZ
is for PostgreSQL. –
Titanate postgres:14.1
image too. –
Semitics SET TIME ZONE 'GMT+2';
? ref: https://mcmap.net/q/143126/-postgres-default-timezone –
Titanate 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
in 2023
if you are using some IDEs PG's client it could require additional info about your time zone
here is additional info of how it could be fixed
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"
© 2022 - 2024 — McMap. All rights reserved.