Heroku, Rails, and Postgres: Get with the Timezone!

By Joe Sak  ·   March 14, 2013  ·  1 minute read

Quick instructions to get your rails, heroku, and postgresql timezone settings working in harmony.

My published_at field isn’t working right! When I publish for right now, or even earlier today, it’s still not showing up on my index list! What the hell?

If you’re like me, you’ve been in this position. And after lots of trial and error, I think I’ve finally cornered the two settings you should put into place to make your timezone settings all work out:

  1. heroku config:add TZ=[INSERT TIME ZONE HERE] (reference list of timezone formats)
  2. and in config/application.rb , make sure to match the config.time_zone setting (reference list of Rails time zone formats)

That’s it! That’s what’s working for us! It seems so simple, but is easy to forget and honestly a bit confusing. To be fair, I could swear I’ve seen it work properly with a combination of settings (maybe set the config in heroku, but not the application file, for example), but this seems to finally be working as we want it.