I have an object attribute of the DateTime class.
How would I understand if the saved date is today, tomorrow or else later?
Here are some useful ways to achieve it:
datetime = DateTime.now => Sun, 26 Oct 2014 21:00:00 datetime.today? # => true datetime.to_date.past? # => false (only based on date) datetime.to_date.future? # => false (only based on date) datetime.to_date == Date.tomorrow # => false datetime.to_date == Date.yesterday # => false
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