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 %>

About these ads

Actions

Information

One response

4 01 2008
Akhil Bansal

Wow,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.

%d bloggers like this: