7

What's the Heroku timezone for Scheduler? It says "UTC" but I'm not sure if that's correct. My tasks are starting at the wrong time despite converting the timezone correctly.

Thoughts?

netwire
  • 7,108
  • 12
  • 52
  • 86

1 Answers1

4

This question's a bit old, but yes, Heroku Scheduler definitely uses UTC even if you specify a timezone in your app. I tested it with this code:

task :send_test_email => :environment do
  if Date.today.strftime("%A").downcase == 'monday'
    UserMailer.send_test_email(Time.now.strftime("%Z")).deliver
  end
end

I'm in Pacific time zone. I set Heroku Scheduler to run this every 10 minutes, and this email was able to send on Sunday night PST, which is Monday in UTC time. Also, the string I passed to the mailer,Time.now.strftime("%Z"), is set as the subject of the email which indeed read, "UTC"

One potential source of confusion is Daylight Saving Time. For example, UTC is always 8 hours ahead of Pacific Standard Time (PST - used for winter months), and 7 hours ahead of Pacific Daylight Time (PDT - used for summer months). So if your tasks are off by an hour, it could be you measured from the wrong UTC zone.

n_i_c_k
  • 1,504
  • 10
  • 18