views:

61

answers:

2

There seems to be a time difference on heroku server.

>> Customer.last.id
=> 584
>> Customer.last.created_at
=> Thu, 06 May 2010 01:43:20 UTC +00:00
>> Time.zone
=> #<ActiveSupport::TimeZone:0x2b1dec47e5c0 @utc_offset=0, @tzinfo=#<TZInfo::DataTimezone: Etc/UTC>, @name="UTC">
>> Time.now
=> Wed May 05 19:05:15 -0700 2010
>> Time.now.zone
=> "PDT"

Notice that current time is May 05 19...however, created_at date for last record is May 06 01:43.

This does not make any sense. What can be causing this and how would I go about fixing this?

A: 

The first time is UTC, not your local time zone. Adjusting for localtime it was created_at 6:43 PM on May 5.

Joe
Can something be done on my application's code to make the time be PDT time?
railsnew
A: 

Rails stores times from your app in the database as UTC so that it can then convert it on the fly to the time zone you specify in environment.rb

This url should explain it all http://mad.ly/2008/04/09/rails-21-time-zone-support-an-overview/

concept47