Default Time zone Setup for PostgreSQL Database

Database
Feb 10 2021
773 Views

Default Time zone Setup for PostgreSQL Database

As we are using triggers in PostgreSQL to fill Created Date or Modified Date with current datetime, you need to ensure that you set the correct time zone for your location. By default PostgreSQL gives UTC datetime.

Step 1
Connect database using PgAdmin client. Use below command to get current timezone.

SHOW TIMEZONE;

Step 2
Make sure to have exact name of the time zone you want to set, you can use the below command to get the complete list of all PosgreSQL time zones.

SELECT * FROM pg_timezone_names;

Step 3

Set the PostgreSQL time zone

SET TIMEZ>

Now check for new timezone

SHOW TIMEZONE;

Conclusion
Its good to handle at database level instead of query specific. 

Leave a Reply