Hello again everyone.
sorry to bother you again with another problem. but i am have a lot of trouble trying to work out the MK () time function.
i have a code that determine the age of a person , the code works well. however when i tried to put the code into a function it stopped working and returns Zero date of birth .
it might be easier if i show you what i mean,
//this is the function that determines the age
$ageTime = mktime(0, 0, 0, 9, 9, 1919); // Get the person's birthday //timestamp
$t = time(); // Store current time for consistency
$age = ($ageTime < 0) ? ( $t + ($ageTime * -1) ) : $t - $ageTime;
$year = 60 * 60 * 24 * 365;
$ageYears = $age / $year;
echo 'You are ' . floor($ageYears) . ' years old.';
//the script above works well enough. it is not enteirly accurate, i.e misses the // //days of a leap year. it is however accurate enough for my purposes.
//the problem however is that when i place this script into a fuction it no longer //works
function bithday ( $time )
{
$ageTime = mktime( $time ); // Get the person's birthday timestamp
$t = time(); // Store current time for consistency
$age = ($ageTime < 0) ? ( $t + ($ageTime * -1) ) : $t - $ageTime;
$year = 60 * 60 * 24 * 365;
$ageYears = $age / $year;
$birthdate = floor($ageYears) ;
return $birthdate;
}
echo bithday ( 0, 0, 0, 9, 9, 1975 );
//i placed it into a function so that i could be used within a website script