How to set time zone for datetime_select helper

I need help. I have this code:

<%= f.datetime_select :date,  :start_year => 2011 %>

the output is good except timezone ... utc timezone and I want to change it to a different timezone. How should I do it? Do I need to do something in initializers? I found some things on the Internet, but they were on rails 2 and they did not work.

Thanks a lot, I need quick help :)

gal harth

I am stuck in this question, please help me !!! :)

+3
source share
1 answer

I have this in my rails3 application.rb

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
config.time_zone = 'Berlin'

it would be interesting to hear if this helps, or if datetime_select itself accepts the time zone.

And I just found this railscast that can help:

http://railscasts.com/episodes/106-time-zones-in-rails-2-1

+5

All Articles