Skip to content

Instantly share code, notes, and snippets.

@stan
Created August 22, 2010 06:57
Show Gist options
  • Save stan/543448 to your computer and use it in GitHub Desktop.
Save stan/543448 to your computer and use it in GitHub Desktop.
# http://www.jroller.com/obie/entry/quickly_generate_random_dates_in
class Time
def self.random(years_back=5)
year = Time.now.year - rand(years_back) - 1
month = rand(12) + 1
day = rand(31) + 1
Time.local(year, month, day)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment