Feature Request #4694

Add Date::age_from_birthdate function

Added by Valeriy Volkov about 2 years ago. Updated about 2 years ago.

Status:NewStart date:01/28/2013
Priority:NormalDue date:
Assignee:-% Done:


Target version:-
Resolution: Points:1


It will be usefull to have this function in kohana


#1 Updated by Josh Buckley about 2 years ago

Wouldn't that essentially be DateTime::diff()? (http://php.net/manual/en/datetime.diff.php)

#2 Updated by Jeremy Bush about 2 years ago

I don't see a reason this should be added anyway. It seems awfully use-case specific.

#3 Updated by Haralan Dobrev about 2 years ago

If ever implemented here is the best birthday to age conversion I've seen:

// Given the birthday is in YYYY-MM-DD format
list($year, $month, $date) = explode('-', $birthday);

$age = (int) date('Y') - (int) $year;
$months = (int) date('m') - (int) $month;
$days = (int) date('d') - (int) $date;

if ( $months < 0 OR ($months === 0 AND $days < 0))

However I am against adding that to the core. But if someone comes here someday, this might help him to not look for such functionality from a framework.

Also available in: Atom PDF