I was this old on

MY_BIRTHDAY = Date.new(1982,5,24)

  def years_old_on(adate)
    (adate - MY_BIRTHDAY).to_i/365
  end

hint: pass it a date object, and set MY_BIRTHDAY to your birthday.
e.g.:

years_old_on(Date.new(1993,7,6)) #=> 11

Comments are closed.

About

QuirkeyBlog is Aaron Quint's perspective on the ongoing adventure of Code, Life, Work and the Web.

twitter/@aq.

instagram/@quirkey.

github/quirkey.

QuirkeyBlog is proudly powered by WordPress

Categories