Change RDS PostgreSQL time zone

Updated at:

This topic describes how to view supported time zones and change the time zone for an RDS PostgreSQL instance using SQL in Data Management (DMS).

Prerequisites

Before you begin, ensure that you have:

  • An ApsaraDB RDS for PostgreSQL instance

  • Access to DMS for the instance

Change the time zone

  1. Log on to the ApsaraDB RDS for PostgreSQL instance by using DMS.

  2. In the top navigation bar, choose SQL Operations > SQL Window.

  3. View the supported time zones.

    SELECT * FROM pg_timezone_names;

    Time zone names follow the Region/City format, for example, America/New_York or Asia/Shanghai. To find a specific time zone by keyword, use a case-insensitive search:

    SELECT * FROM pg_timezone_names WHERE name ILIKE '%new_york%';
  4. Set the time zone for all roles.

    ALTER ROLE ALL SET timezone='<time-zone-name>';

    Replace <time-zone-name> with a name from the pg_timezone_names view. For example:

    ALTER ROLE ALL SET timezone='UTC';
  5. Verify that the time zone has been updated.

    SELECT * FROM pg_db_role_setting;

    Confirm that the setconfig column shows the expected time zone value.