Reputation: 563
They both seem to do the same thing. I'm just worried that one uses timezones differently to the other.
Upvotes: 56
Views: 28566
Reputation: 2048
If you're doing comparisons you should always use Date.current
This is because if you're in a timezone that could be in a different day than UTC, and your timezone isn't set then you can have the situation where Date.today == Date.tomorrow
Upvotes: 31
Reputation: 115541
See Rails code, line 40 here.
# Returns Time.zone.today when <tt>Time.zone</tt> or <tt>config.time_zone</tt> are set, otherwise just returns Date.today.
def current
::Time.zone ? ::Time.zone.today : ::Date.today
end
So If you defined a timezone, you'll get a zoned Date otherwise you'll get Date.today
.
BTW there is no Date.now
Upvotes: 94