logging - Why does Heroku log using the server time rather than the Rails time zone? -
update: ok, didn't formulate q answered. still struggle heroku being on -07:00 utc , @ +02:00 utc.
q: how log written in correct time.zone ? 9 hours difference, heroku (us west) - norway, distracting work with. in production.log (using heroku logs
):
processing productioncontroller#create xml (for 81.26.51.35 @ 2010-04-28 23:00:12) [post]
how write 2010-04-29 08:00:12 +02:00 gmt
?
note i'm running @ heroku , cannot set server time myself, 1 @ amazon ec2 servers. below previous question, i'll leave holds interesting information time , zones.
why time.now
yield server local time when have set time zone in environment.rb
config.time_zone = 'copenhagen'
i've put in 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 result on app @ 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 correct result. have switch time.now
time.zone.now
, everywhere? seems cumbersome. don't care local time of server is, it's giving me loads of trouble due extensive use of time.now
. misunderstanding fundamental here?
after further investigation own heroku timezone problems, found post indicates can specify timezone @ application level, using following command:
heroku config:add tz=europe/oslo
i believe may answer troubles. courtesy of http://www.reality.hk/articles/2010/01/07/1319/ (edit: broken link of 2012.08.23. archived copy.)
Comments
Post a Comment