简体   繁体   中英

PostgresQL TImezone in Google Cloud SQL

How do I set a permanent timezone in Google Cloud SQL's PostgreSQL Instance?

I have tried with set timezone to 'Asia/Kathmandu'; but it resets to UTC on restart.

I have also tried with alter database "dbname" set timezone = "Asia/Kathmandu"; which sustains a restart but if anyone else connects to that Database, they have UTC Time when select now(); .

There is a feature request for a flag to set the timezone for the Cloud SQL instance.

For the moment Cloud SQL PostgreSQL does not currently support time zone changes at the global scope becuase it requires SUPERUSER privileges. If you want to change it at the session scope, you can execute it with the following command.

SET timezone "database name" to 'Asia/Kathmandu';

Another alternative to persist the change as you previously mentioned is to use the command:

ALTER DATABASE <dbname> SET TIMEZONE TO 'Asia/Kathmandu';

or

ALTER USER <username> SET TIMEZONE TO 'Asia/Kathmandu';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM