User model has time_zone, which stores say “Pacific Time (US & Canada)”.
Scenario:
1. Current_user lives in Japan timezone
2. Current_user is viewing profile of John who lives in “Pacific Time (US & Canada)”
3. On John’s profile, I need to show local time at “Pacific Time (US & Canada)” as 10:01 am
What I did?
ActiveSupport::TimeZone.new(@user.time_zone).now returns something like 2011-09-21 10:01:56 UTC
Questions:
1. How to do I convert this to 10:01 am?
2. Why is it UTC?
Please help
To set TimeZone, you need to use
You may want to set this in :before_filter in
application.rbOTOH, you can use
use_zonemethod with a block