Forum: Ruby on Rails Time Zone changing with strftime?

B6a2e2c1454c56eb686c5a38b5f73d02?d=identicon&s=25 Joel Dezenzio (elricstorm)
on 2011-07-08 18:17
Why is strftime changing the date to UTC when I have the time zone set
and the DB results show the correct datetime format?

In Schedules Database:

Column date_scheduled = 2011-09-11 16:15:00

schedule.date_scheduled.strftime("%I:%M %p")
=> 12:15 PM  (should show 4:15 PM)

In application.rb:

config.time_zone = 'Eastern Time (US & Canada)'

Does time_zone configuration not work in Rails 3?  Little things like
this drive me batty because I think they work a particular way and then
I find they do not.

The time in my entire rails app should be defaulting to Eastern Time
only, regardless of who views my site.
B6a2e2c1454c56eb686c5a38b5f73d02?d=identicon&s=25 Joel Dezenzio (elricstorm)
on 2011-07-08 18:24
And, in case someone says to use "in_time_zone", you can't use that with
a string.  I've already had to force convert my time zone components
from UTC into the database using in_time_zone.  But, I don't believe I
should have to force another time conversion in order to format a time
string.
B6a2e2c1454c56eb686c5a38b5f73d02?d=identicon&s=25 Joel Dezenzio (elricstorm)
on 2011-07-08 21:05
The answer:

application.rb

config.active_record.time_zone_aware_attributes = false
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.