Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List the time zones for a Country

I am looking for the code that displays list of countries/regions in ruby on rails when selecting a specific country/region, it displays the time zone of it. For example when i choose “United Kingdom" as country/region then it should displays “(GMT +00:00)London" as Time Zone. My application runs on Rails 3.2.11. I am displaying all the countries using countries gem and all the time zones using ActiveSupport::TimeZone. I want to know if Ruby on Rails provide this functionality by default or if there is any other possible way to achieve this.

like image 448
Shabini Rajadas Avatar asked Oct 29 '25 17:10

Shabini Rajadas


1 Answers

In Rails 5.2 this is simple: ActiveSupport::TimeZone.country_zones("US")

like image 82
tfwright Avatar answered Oct 31 '25 08:10

tfwright