Hermine D. Hermine D. - 11 months ago 28
Ruby Question

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

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

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

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