Re: age

From: Date: Sun, 05 Aug 2001 20:21:48 +0000
Subject: Re: age
Groups: php.general 
Request: Send a blank email to php-general+get-61352@lists.php.net to get a copy of this message
Here's something I use for a date string that looks like mm/dd/yyyy to turn the date into an age from the current date. $age = explode("/", $bdate); $userage = date("Y") - $age[2]; if($age[0] > date("m") || ( $age[0] == date("m") && $age[1] > date ("d"))) { --$userage; } if($userage > 50) { $userage = ""; } I did not compensate for leap years, however. You could use my code, and it should work fine, but the first line where I do an explode, you'd have to change that to turn your date string into #'s like I use.. > > does any one know where i can get a script that will convert a birthdate in to an age. i have one half written however i have incounter difficulties with dealing with leap years. perhaps soem one would know the solution . .. or just a premade script is fine > > > $test = strtotime ("January 12, 1944"); > $test2 = strtotime ("January 9, 1954"); > > $oneyear = 3600 * 24 * 365; > > $diff = $test2 - $test; > $ans = $diff/$oneyear; > > echo $ans; > > > > > > Thank You, > > Jon Yaggie > www.design-monster.com > > And they were singing . . . > > '100 little bugs in the code > 100 bugs in the code > fix one bug, compile it again > 101 little bugs in the code > > 101 little bugs in the code . . .' > > And it continued until they reached 0 > > > > Corey Chapman Xnull CEO (Chat with us: http://forum.xnull.com)

« previous php.general (#61352) next »