How to display the time in user's timezone

后端 未结 8 1208
深忆病人
深忆病人 2020-11-30 05:42

I am using rails 3.0.5 and I have created_at and updated_at stored in UTC. Now I want to display the created_at time in users\' timezone. I believe it is possible to pick us

8条回答
  •  离开以前
    2020-11-30 05:57

    http://api.rubyonrails.org/classes/Time.html#method-c-use_zone

    This is what you're looking for :

    Time.use_zone(@user.timezone) do
      blah blah blah
    end
    

提交回复
热议问题