Re: How do you get someone's age from DOB?
- From: "comp.lang.php" <phillip.s.powell@xxxxxxxxx>
- Date: 30 Jan 2006 12:08:58 -0800
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@xxxxxxxxxxxxxxxxxx
> (remove NOSPAM to contact me directly)
.
- Follow-Ups:
- Re: How do you get someone's age from DOB?
- From: Justin Koivisto
- Re: How do you get someone's age from DOB?
- References:
- How do you get someone's age from DOB?
- From: comp.lang.php
- Re: How do you get someone's age from DOB?
- From: Kim André Akerø
- How do you get someone's age from DOB?
- Prev by Date: Accessing PHP serialized data in C++
- Next by Date: Re: need help getting php working
- Previous by thread: Re: How do you get someone's age from DOB?
- Next by thread: Re: How do you get someone's age from DOB?
- Index(es):
Relevant Pages
|