Is Time.zone.now.to_date
equivalent to Date.today
?
Another way to put it: will Time.zone.now.to_date == Date.today
always be true
?
If not, what's the best way to get a Date object corresponding to "now" in the application time zone?
Is Time.zone.now.to_date
equivalent to Date.today
?
Another way to put it: will Time.zone.now.to_date == Date.today
always be true
?
If not, what's the best way to get a Date object corresponding to "now" in the application time zone?
They are certainly not equivalent in terms of being the "same":
>> Time.zone.now.class
=> ActiveSupport::TimeWithZone
irb(main):007:0> Date.today.class
=> Date
However, they are very loosely equivalent in returning the same date (not time) information:
irb(main):014:0> Date.today.to_s
=> "2009-12-20"
>> Time.zone.now
=> Sun, 20 Dec 2009 21:48:05 UTC +00:00