How do I change the timezone of Postgres database in the Azure Cloud

John Butler 1 Reputation point
2022-03-30T22:27:11.25+00:00

I need to change the timezone of one of my Postgres SQL databases I have in the MS Azure cloud from America/Los_Angeles to UTC.

I have gone to the Server Parameters page and changed the timezone to UTC, but when I connect to the database using psql or other tool and do a select current_timestamp when connected to the database is still returns the time in America/Los_Angeles time.

Also when I do a show timezone it returns America/Los_Angeles.

Azure Database for PostgreSQL
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Takahito Iwasa 4,851 Reputation points MVP Volunteer Moderator
    2022-03-31T07:18:57.777+00:00

    Hi. @John Butler

    I changed the timezone in Single Server of Azure Database for Postgresql and checked it. (Asia / Tokyo <-> UTC)

    It worked fine.

       postgres=> show timezone;  
         TimeZone    
         
       \------------  
         
        Asia/Tokyo  
       (1 row)  
         
       postgres=> select * from current_timestamp;  
              current_timestamp         
         
       \-------------------------------  
         
        2022-03-31 16:15:31.805027+09  
       (1 row)  
    
    
    
       postgres=> show timezone;  
        TimeZone   
         
       \----------  
         
        UTC  
       (1 row)  
         
       postgres=> select * from current_timestamp;  
              current_timestamp         
         
       \-------------------------------  
         
        2022-03-31 07:16:13.477177+00  
       (1 row)  
    

    Did you save after making changes on the parameter screen?
    Or does the server you are connecting to match the server you are checking on the portal?

    188661-image.png


  2. John Butler 1 Reputation point
    2022-04-01T22:41:48.477+00:00

    I figured this one out. The desktop tool I was using - DBVisualizer Pro 12 was intercepting my show timezone, select current_setting(), select now() and select current_timestamp commands and translating them to values contained in the Properties configuration for the tool.

    When I issue these commands from native psql or pgAdmin4 the timezone parameter and current time both show UTC.

    Thanks for your help

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.