Already a few hours I am struggling with the storing time into database table. The time is there saved like -1h. I don’t know how to smartly print the time from database with the right shape (= +1h). I tried set timezone and stuffs like that, but unfortunately nothing works me.
So as the solution I choose this way:
@my_obj.created_at+3600 # +1 hour
Exist any better way to do it?
Once you’ve set the server’s timezone you can use:
?
For more info: have a look at the apidock on this method here: http://apidock.com/rails/ActiveSupport/TimeZone/utc_to_local
If you need to override the server’s local timezone, you could set it as a before_filter in your ApplicationController:
Again apidock is good for more info: http://apidock.com/rails/Time/zone%3D/class
If you don’t want to rely on the server’s local timezone, you can always use: