Skip to content

Instantly share code, notes, and snippets.

@fguillen
Created January 4, 2009 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fguillen/43158 to your computer and use it in GitHub Desktop.
Save fguillen/43158 to your computer and use it in GitHub Desktop.
def random_datetime( date_ini = '1970/01/01 10:10', date_end = '2010/01/01 10:10' )
time_ini_int = Time.parse( date_ini ).to_i
time_end_int = Time.parse( date_end ).to_i
time_random_int = Kernel.rand( time_end_int - time_ini_int ) + time_ini_int
return Time.at( time_random_int )
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment