Last active
August 29, 2015 14:11
-
-
Save Linell/cad1bd242ea8f49312ab to your computer and use it in GitHub Desktop.
Generates a random date between two given dates.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def random_date | |
date1 = DateTime.new(2014,8,1) | |
date2 = DateTime.now() | |
Time.at( (date2.to_f - date1.to_f)*rand + date1.to_f).to_date | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment