Forum: Ruby on Rails Time Zone changing with strftime?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Joel D. (Guest)
on 2011-07-08 20: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.
Joel D. (Guest)
on 2011-07-08 20: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
Joel D. (Guest)
on 2011-07-08 23:05
The answer:


config.active_record.time_zone_aware_attributes = false
This topic is locked and can not be replied to.