Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Created September 23, 2018 12:31
Show Gist options
  • Save harrisonmalone/b0930b029c3c3e19ab5655bf6035b832 to your computer and use it in GitHub Desktop.
Save harrisonmalone/b0930b029c3c3e19ab5655bf6035b832 to your computer and use it in GitHub Desktop.
require 'date'
def days_since_born(year, month, day)
date = Date.new(year, month, day)
p date
today = Date.today
p today
result = (today - date).to_i
sentence = "I have been alive for #{result} days"
return sentence
end
p days_since_born(1993, 03, 30)
# remember that you can subtract two different date objects to get the difference in date, all you need is a to_i to convert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment