This project is archived and is in readonly mode.
Time saved as UTC but read as localtime
Reported by joserwan | March 18th, 2010 @ 07:18 PM
Maybe it's a choice, but when you save an object, updated_at for exemple is saved as UTC, but when you do a query for read, time is not converted into UTC time. (sorry for my english !)
Exemple :
d = MyObject.last
=> #
d.created_at => Tue, 16 Mar 2010 15:56:53 UTC +00:00 d.created_at = Time.now => Thu Mar 18 15:01:22 -0400 2010 d.save => true d.created_at => Thu, 18 Mar 2010 19:01:22 UTC +00:00 timestamp = d.created_at.localtime.to_i => 1268938882 Peer.find_by_created_at(timestamp) Peer Load (0.9ms) SELECT * FROM
my_objects
WHERE (my_objects
.created_at
= '2010-03-18 15:01:22') LIMIT 1
=> nil
Comments and changes to this ticket
-
joserwan March 18th, 2010 @ 07:20 PM
ugly formatting !
Exemple :
d = MyObject.last => # >> d.created_at => Tue, 16 Mar 2010 15:56:53 UTC +00:00 >> d.created_at = Time.now => Thu Mar 18 15:01:22 -0400 2010 >> d.save => true >> d.created_at => Thu, 18 Mar 2010 19:01:22 UTC +00:00 >> timestamp = d.created_at.localtime.to_i => 1268938882 >> Peer.find_by_created_at(timestamp) Peer Load (0.9ms) SELECT * FROM `my_objects` WHERE (`my_objects`.`created_at` = '2010-03-18 15:01:22') LIMIT 1 => nil
-
José Valim March 27th, 2010 @ 01:54 PM
- State changed from new to wontfix
It's always saved in the database as UTC. You can configure the format on READ by changing config/environment.rb.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>