Reputation: 1792
I have a model with a datetime field, and is stored in UTC, how can I display that date in simple form gem in a specific timezone?
Already tried with the option input_html: {value: @model.date.in_time_zone('Eastern Time (US & Canada)')}
Note: I can't change the timezone of rails app
Upvotes: 7
Views: 2133
Reputation: 1792
It will work if you set the timezone in the controller:
Example:
around_action :set_time_zone, if: :current_user
private
def set_time_zone(&block)
Time.use_zone(current_user.time_zone, &block)
end
Upvotes: 6