How to convert Time.now to Date

Sometimes I need to compare a date field in my database to todays date. Ruby doesn’t have a Date class only Time with the method Time.now. To turn Time.now into a date, I now do the following thanks to Ruby convert Time to Date

Date.parse(Time.now.strftime('%Y/%m/%d'))

Also, here’s the Ruby Time class

Comments