Reputation: 8451
Let's say I have this string saved as a "time_zone" on my "Event" model.
"America/Chicago"
I'd like to convert that value to the abbreviated representation. So, that would ideally look like this
"EST"
Is there a standard Rails method for making this conversion? I haven't been able to find one.
Upvotes: 0
Views: 70
Reputation: 1132
Use ActiveSupport
ActiveSupport::TimeZone["America/Chicago"].tzinfo.current_period.abbreviation.to_s
"CST"
Upvotes: 0