In PostgreSQL, the timezone configuration is essential for handling date and time values accurately, especially when dealing with data from different time zones. The system time zone of the operating system can also influence PostgreSQL's behaviour since, PostgreSQL queries the system for the local time zone if not explicitly configured.
If you want to explicitly configure timezone for the PostgreSQL server, We can set the timezone either of the below methods in appropriate cases.
Pro-tip :
you can find your appropriate timezone value from the list of time zones by executing the below query.
- SELECT * FROM pg_timezone_names;
Check current Timezone by
- SHOW TIMEZONE;
Case 1 : Configuring Timezone for the PostgreSQL server globally, persistent over multiple sessions.
- Navigate to <product_installation_directory> \ pgsql \ ext_conf folder.
- Add/Edit the below entry in 00framework_ext.conf file.
timezone='Asia/Kolkata'
log_timezone='Asia/Kolkata'
3. Restart the PostgreSQL server.
Case 2 : Configuring timezone only to specific databases, persistent over multiple sessions.
- Login into PostgreSQL server in command prompt
- Execute the below SQL query.
ALTER DATABASE servicedesk SET TIMEZONE TO 'America/New_York
3. Restart the PostgreSQL server.
Case 3 : Testing timezone configuration, (persist only in current session)
- Login into PostgreSQL server in command prompt.
- Execute the below SQL query.
SET TIMEZONE to 'America/New_York';
This case, will be useful for testing the appropriate timezone before configuring your database to switch to that timezone.
If you face any issues in configuring the Timezone, Reach our Support Team with the below information.
- Operating system
- Steps followed to set the Timezone.
- PostgreSQL configuration files such as,
- <installation_folder> \ pgsql \ data \ postgresql.conf
- <installation_folder> \ pgsql \ ext_conf folder
- <installation_folder> \ ext_conf \ 00framework_ext.conf file
- PostgreSQL logs generated when setting the timezone, which can be found under " <installation_folder> \ pgsql \ data \ pg_log folder"