Can't set timezone using abbreviation

前端 未结 2 876
天命终不由人
天命终不由人 2021-01-27 14:17

I can\'t set timezone on Rails using its abbreviation, for example:

>> Time.zone = \'BRT\'
ArgumentError: Invalid Timezone: BRT
        from /home/braulio/         


        
2条回答
  •  余生分开走
    2021-01-27 14:54

    You don't have to use around_filter. Put this in before_action

    Time.zone = "Etc/GMT#{gmt_offset}"

    (Time.zone is thread local. It's safe to change.)

提交回复
热议问题