mercredi 8 avril 2015

Confusion in Rails TimeZone

My config for timezones looks like this



config.time_zone = 'Pacific Time (US & Canada)'
config.active_record.default_timezone = 'Pacific Time (US & Canada)'


When I query for created_at of an Object it returns me a value like this



2.1.5 :070 > b.created_at
=> Tue, 07 Apr 2015 20:49:58 PDT -07:00


The DateTime value at the time of creation of the object was like this



2.1.5 :071 > DateTime.now
=> Wed, 08 Apr 2015 03:49:58 -0700


Which means the value I was getting for the created_at field was 7 hours behind PDT.I cannot understand why this happens.Is this because of any mistakes in my configs.


Aucun commentaire:

Enregistrer un commentaire