Hermine D. Hermine D. - 1 year ago 32
Ruby Question

How to generate a random date and time between two dates?

Don't overlook the 'date AND TIME' part though.

Answer Source
Time.at((date2.to_f - date1.to_f)*rand + date1.to_f)

You'll get a time object that is between two given datetimes.