Skip to content

set timezone on Heroku servers

December 29, 2011

Set timezone on Heroku dynos. Tested on cedar stack.

heroku config:add TZ=America/Whitehorse

Set timezone on dedicated PostgreSQL server

  1. get list of timezones from wikipedia
  2. get user id
    heroku pg:info
  3. change time zone
    heroku pg:psql
    ALTER ROLE youruserid SET timezone = 'America/Los_Angeles';

Update from heroku:

The user id will stay the same across forks and follows.

It will change if you request it to be randomly re-generated or if you get a new database and use PGBackups.

Also, there is an important caveat: the ALTER ROLE SET TIMEZONE setting does not persist in PGBackups or pg_dump or pg_restore at this time.

I would suggest having your software automatically run SET TIMEZONE at connection start-up to be the most robust approach because of that problem, but if you must, ALTER ROLE does work.


From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: