|
Posted by Matthew Weier O'Phinney on 09/28/85 11:20
* "Ryan A" <ryan@coinpass.com>:
> This is the code I am using to display a persons age from the mysql db:
>
> $day1=strtotime($age);
> $day2 = strtotime(date("Y-m-d"));
Just to be pedantic... just use time() for the above statement; no
reason to do extra work here. (date() will actually call time() anyways)
> $dif_s = ($day2-$day1);
> $dif_d = ($dif_s/60/60/24);
> $age = round(($dif_d/365.24));
And, as someone else mentioned, you want to do floor() here, as somebody
is 16 until their 17th birthday.
--
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/
Navigation:
[Reply to this message]
|