<?php
class Person {
public $firstName;
public $lastName;
public $birthday;
function calculateAge() {
$age = (time() - $this->birthday) / (365.2422 * 86400);
return floor($age);
}
}
$me = new Person;
$me->birthday = strtotime( "1978-12-22 09:15" );
echo "I am " . $me->calculateAge() . " years old.";
?>
Output
I am 45 years old.