I would like to know, how to get a list of timezones in Ruby 2.0?
Ruby | Time zone() functionTime#zone() : zone() is a Time class method which returns the name of the time zone used for time like “UTC”, “GMT”.
In Rails, to see all the available time zones, run: $ rake time:zones:all * UTC -11:00 * American Samoa International Date Line West Midway Island Samoa * UTC -10:00 * Hawaii * UTC -09:00 * Alaska ... The default time zone in Rails is UTC.
Installation. The TZInfo gem can be installed by running gem install tzinfo or by adding gem 'tzinfo' to your Gemfile and running bundle install . To use the Ruby modules as the data source, TZInfo::Data will also need to be installed by running gem install tzinfo-data or by adding gem 'tzinfo-data' to your Gemfile .
with rails a simple way is:
ActiveSupport::TimeZone.all
If you want a ruby only solution, (rails independent) you can use the tzinfo gem.
require 'tzinfo' TZInfo::Timezone.all_country_zone_identifiers TZInfo::Timezone.all_country_zones #... #America/Chicago #America/Indiana/Tell_City #America/Indiana/Knox #America/Menominee #America/North_Dakota/Center #America/North_Dakota/New_Salem #America/North_Dakota/Beulah #America/Denver #America/Boise #...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With