Rails 4 - how to set a timezone for strftime?

Viewed 6047

Every user in our database can select his/her own timezone. The default timezone of our application Eastern Time:

  config.time_zone = 'Eastern Time (US & Canada)'
  config.active_record.default_timezone = 'Eastern Time (US & Canada)'  

When I display some dates/times in the application, I usually use for that purpose .strftime. How can I give a parameter to strftime to display the date/time properly (in the given timezone for the specific user)?

Or is there a better way than to format every date/time with using strftime?

EDIT:

Every user has a time_zone string column, where is stored the timezone like this: "Eastern Time (US & Canada)". As the every date/time will be re-calculated for every timezone, how about the performance? Will this not slow down too much rendering views?

1 Answers
Related