On Tue, 14 Dec 2004 22:37:41 +0100, Merlin <[EMAIL PROTECTED]> 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/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php