Skip to content

Instantly share code, notes, and snippets.

@wrburgess
Last active September 26, 2021 03:13
Show Gist options
  • Save wrburgess/1944532 to your computer and use it in GitHub Desktop.
Save wrburgess/1944532 to your computer and use it in GitHub Desktop.
Ruby and Date/Time random date in range
date_of_last_entry = Date.parse(Time.at(last_entry).strftime('%Y/%m/%d')) #2011-02-29
Date.today - date_of_last_entry == 0
# get random DateTime in last 3 weeks
DateTime.now - (rand * 21)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment