08-14-2008, 01:47 PM
|
#4 (permalink)
|
|
The Contributor
Join Date: Jan 2008
Location: Maine, USA
Posts: 92
Thanks: 2
|
Quote:
Originally Posted by delayedinsanity
You can still use mktime to get accurate ages.
PHP Code:
function getAge ($month, $day, $year)
{
$now = mktime( 0, 0, 0, date("n"), date("j"), date("Y") );
$then = mktime( 0, 0, 0, $month, $day, $year );
$age = floor((((($now - $then) / 60) / 60) / 24) / 365.25);
return $age;
}
|
I stand partially corrected.
Take a look at the notes section for mktime.
Quote:
Caution
Before PHP 5.1.0, negative timestamps were not supported under any known version of Windows and some other systems as well. Therefore the range of valid years was limited to 1970 through 2038.
|
You need to be really careful if what you're writing has any chance of being used on systems like they describe.
__________________
-- Bill
"Why is it drug addicts and computer aficionados are both called users?" -Clifford Stoll
|
|
|
|