Re: How do you get someone's age from DOB?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: How do you get someone's age from DOB?

From: comp.lang.php <phillip.s.powell@gmail.com>
Date: Mon Jan 30 2006 - 21:08:58 CET

Please go over this line by line, you completely lost me.

Phil

Kim André Akerĝ wrote:
> comp.lang.php wrote:
>
> > Dangit I thought I could do THIS simple task today and even this is
> > beyond me!! :(
> >
> > [code]
> > <?= date(time()) - date(strtotime($result[0]->birth)) ?>
> > [/code]
> >
> > This is completely wrong, but what IS right? I'm stumped!
>
> More like this:
> http://james.cridland.net/code/age.html
>
> In your case, the code would be:
>
> <?php
>
> $birthdate = strtotime($result[0]->birth);
> $age = date("Y") - date("Y",$birthdate);
> if ((date("n") < date("n",$birthdate)) or ((date("n") ==
> date("n",$birthdate)) and (date("j") < date("j",$birthdate)))) {
> $age--;
> }
>
> echo $age;
>
> ?>
>
> --
> Kim André Akerĝ
> - kimandre@NOSPAMbetadome.com
> (remove NOSPAM to contact me directly)
Received on Tue Feb 7 21:07:54 2006