Skip to main content

How to change timezone in PostgreSQL RDS server on AWS

I was facing some troubles the other day in a PostsgreSQL RDS created in N.Virginia AWS,  the RDS' timezone had to be synchronized in Colombia and as there are not any postgresql.conf in an AWS RDS in order to make that change you must connect to the database through the console, in my case I did something like this

username = postgres
database = postgres
endpoint = test.chwc4bq271vn.us-east-1.rds.amazonaws.com

psql -U postgres -h test.chwc4bq271vn.us-east-1.rds.amazonaws.com  -p 5525 -d postgres ( replace all these by your credentials and your endpoint )

after you set the password and you get to the prompt run this 

alter database postgres set timezone TO 'America/Bogota';

change the time zone by the one you need, or run this command to list the available zones:

select * from pg_timezone_names ;


after you have done the process, test it creating a table which you give it an id and it sets automatically the date


CREATE TABLE public."TimeTest"
(
   id integer, 
   time1 timestamp without time zone DEFAULT now(), 
   time2 timestamp with time zone DEFAULT now(), 
   CONSTRAINT "PK" PRIMARY KEY (id)
WITH (
  OIDS = FALSE
);

and on that way, you can prove that the date is being saved according to the local time you have set

Comments

Post a Comment