KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'd like to get a person's age from its birthday. now - birthday / 365 doesn't work, because some years have 366 days. I came up with the following code: now = Date.today year = now.year - birth_date.year if (date+year.year) > now year = year - 1 end Is there a more Ruby'ish way to calculate age?
Tags (comma-separated)
Save Edits
Cancel