Ruby on Rails Saturday, April 2, 2011

I want to store, retrieve and handle all times inside my app in just one
Timezone. => "New Delhi"

for that I've set in my application.rb file,

config.time_zone = "New Delhi"

When i create a record like

Event.create(:when => DateTime.new(2011, 5, 7, 16, 0, 0))

it creates an event record in my mysql db (local) with "when" field as
"2011-05-07 16:00:00"

but when I go to console and retrieve the event date like
>> Event.first.when
>> Sat, 07 May 2011 21:30:00 IST +05:30

It should have given me this instead...
>> Sat, 07 May 2011 16:00:00 IST +05:30

But when I ask for rails about the timezone in console, it gives me this
>> Time.zone
>> (GMT+05:30) New Delhi

Am I missing something for configuration? I am not able to understand
Timezone
and its settings concept in rails3.0. I find very little documentation
or text on this subject in internet.. Can you please help me understand
the concept here...


:) thanks
fellow rubyist..

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment