They both seem to do the same thing. I'm just worried that one uses timezones differently to the other.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With