Skip to content

Instantly share code, notes, and snippets.

@rvbsanjose
Created October 7, 2012 10:15
Show Gist options
  • Save rvbsanjose/3847767 to your computer and use it in GitHub Desktop.
Save rvbsanjose/3847767 to your computer and use it in GitHub Desktop.
Birthday timestamp
def birthday_timestamp(date)
date = date.split('/')
month, day, year = date.pop(3)
birthday = Time.mktime(year, month, day)
time_now = Time.now
years = time_now.year - birthday.year
months = time_now.month - birthday.month
days = time_now.day - birthday.day
puts "#{years} years #{-months} months #{-days} day old" if days < 2
puts "#{years} years #{months} months #{days} days old" if days > 2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment