you are here: codestackercodes [RSS] → tag age [RSS]

age calculation

# one method

def age
 ((Time.now - birthday)/(60*60*24)/365.2422).to_i
end

# second method

def birthday
    @birthday = Time.local( birth_year, birth_month, birth_day )
  end
  
  def age
    ((Time.now - birthday) / 1.year).to_i
  end 
Displaying 1 Code