heroku time zone problem

Posted by Ole Morten Amundsen on Stack Overflow See other posts from Stack Overflow or by Ole Morten Amundsen
Published on 2010-04-27T07:04:59Z Indexed on 2010/04/27 7:13 UTC
Read the original article Hit count: 592

Filed under:
|
|
|

Why does Time.now yield the server local time when I have set the another time zone in my environment.rb

config.time_zone = 'Copenhagen'

I've put this in a view

  <p> Time.zone <%= Time.zone %> </p>
  <p> Time.now <%= Time.now %> </p>
  <p> Time.now.utc <%= Time.now.utc %> </p>
  <p> Time.zone.now <%= Time.zone.now %>  </p>
  <p> Time.zone.today <%= Time.zone.today %> </p>

rendering this result on my app at heroku

Time.zone (GMT+01:00) Copenhagen

Time.now Mon Apr 26 08:28:21 -0700 2010

Time.now.utc Mon Apr 26 15:28:21 UTC 2010

Time.zone.now 2010-04-26 17:28:21 +0200

Time.zone.today 2010-04-26

Time.zone.now yields the correct result. Do I have to switch from Time.now to Time.zone.now, everywhere? Seems cumbersome. I truly don't care what the local time of the server is, it's giving me loads of trouble due to extensive use of Time.now. Am I misunderstanding anything fundamental here?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about time