Why does Heroku log using the server time rather than the Rails time zone?

后端 未结 3 1846
灰色年华
灰色年华 2020-12-12 17:23

UPDATE: Ok, I didn\'t formulate a good Q to be answered. I still struggle with heroku being on -07:00 UTC and I at +02:00 UTC.

Q: How do I get the log writte

3条回答
  •  庸人自扰
    2020-12-12 18:09

    Without being able to change the actual server time (which I don't think you'll be able to do on Heroku), your only option is to convert the times yourself.

    If Time.zone.now is too cumbersome, you could set a global timezone using the tzinfo gem:

    $tz = TZInfo::Timezone.get("Europe/Oslo")
    $tz.now # current time in Norway
    

    But this is still a global change in your app and not significantly different from what you're doing.

提交回复
热议问题