time_zone_select showing only US time zones

4 01 2008

time_zone_select produces option tags for almost any time zones in the world but if you want the list of US time zones only, without using the TZInfo library then you should add a file under the lib directory say us.rb and add the following code

class US
 def self.all
  TimeZone.us_zones
 end
end

and in you views use

<%= time_zone_select object, method, nil, :model=>US %>

Advertisements