Home > Blockchain >  Cannot set the timezone of Postgresql role
Cannot set the timezone of Postgresql role

Time:03-09

The official Postgresql recognized timezones says Iran Time is IT so why I get this error? It's version 12 if matters.

postgres=# alter role myuser set timezone to 'IT';
ERROR:  invalid value for parameter "TimeZone": "IT"

CodePudding user response:

Well, you shouldn't read the manual of outdated and discontinued versions. The fact that the page doesn't exist any longer for supported versions should have made you suspicious.

Modern Postgres versions provide the view pg_timezone_names to check for valid timezone names.

If you run

select *
from pg_timezone_names
where name ilike '%iran%'

you will get this result:

name abbrev utc_offset is_dst
Europe/Tirane CET 01:00:00 f
posix/Europe/Tirane CET 01:00:00 f
posix/Iran 0330 03:30:00 f
Iran 0330 03:30:00 f

so there is no such abbreviation (any more). You will need to use the name:

alter role myuser set timezone to 'Iran';

Note that the result also depends on the operating system on which the Postgres server is running. On Windows you wouldn't get the posix time zones.

  • Related