Re: finding out the age from a birthdate

From: Date: Wed, 15 Dec 2004 17:20:20 +0000
Subject: Re: finding out the age from a birthdate
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-204418@lists.php.net to get a copy of this message
On Tue, 14 Dec 2004 22:37:41 +0100, Merlin <news.groups@web.de> wrote: > i am somehow strugling to find out how to get the age of a person from its > birthdate. > > Has anybody an idea how to do that? function getAge( $b ) { $b = date( 'Y-m-d', strtotime( $b ) ); $a = explode( '-', $b ); $age = date( 'Y-m-d' ) - $b; return ( date( 'nd' ) < $a[ 1 ].str_pad( $a[ 2 ], 2, '0', STR_PAD_LEFT ) ) ? $age -= 1 : $age; } echo getAge( $birthday ); -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/

« previous php.general (#204418) next »