>> ps.cancel_at
=> Fri, 05 Oct 2012 00:00:00 UTC +00:00
>> ps.cancel_at.class
=> ActiveSupport::TimeWithZone
>> ps.cancel_at = DateTime.new 2012, 11, 05
=> Mon, 05 Nov 2012 00:00:00 +0000
>> ps.save
(0.2ms) BEGIN
Entity Load (0.5ms) SELECT "entities".* FROM "entities" WHERE "entities"."id" = 2485 LIMIT 1
Product Load (0.7ms) SELECT "products".* FROM "products" WHERE "products"."id" = 32445 LIMIT 1
(0.8ms) UPDATE "product_subscriptions" SET "cancel_at" = '2012-11-05 00:00:00.000000', "updated_at" = '2012-10-05 22:16:42.029113' WHERE "product_subscriptions"."id" = 6762
(1245.9ms) COMMIT
=> true
>> ps.cancel_at = Time.local 2012, 11, 05
=> 2012-11-05 00:00:00 -0700
>> ps.save
(0.2ms) BEGIN
(0.5ms) UPDATE "product_subscriptions" SET "cancel_at" = '2012-11-05 07:00:00.000000', "updated_at" = '2012-10-05 22:17:32.097390' WHERE "product_subscriptions"."id" = 6762
(0.4ms) COMMIT
=> true
>>
Created
October 5, 2012 22:19
-
-
Save cjolly/3842778 to your computer and use it in GitHub Desktop.
DateTime vs Time and ActiveRecord
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Something we could consider is our
nice_date
helper, perhaps adding aprecise_date
which normalizes to a set TZ regardless of logged_in user's TZ.