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:27:17 CET

I would never have gotten that one. We need a DBA here badly.

Thanx
Phil

Justin Koivisto wrote:
> comp.lang.php wrote:
> > Dangit I thought I could do THIS simple task today and even this is
> > beyond me!! :(
>
> If you're using mysql to get the "birth" field, why not add a field in
> the query:
> FLOOR((CURDATE() - DOB)/10000) AS age
>
> > [code]
> > <?= date(time()) - date(strtotime($result[0]->birth)) ?>
> > [/code]
> >
> > This is completely wrong, but what IS right? I'm stumped!
>
> This depends on how your server handles timestamps. For instance, does
> it support negative ones (before 1970)? I've found using SQL queries to
> calculate age generally work much better as it seems to be consistent
> between platforms/servers.
>
> --
> Justin Koivisto, ZCE - justin@koivi.com
> http://koivi.com
Received on Tue Feb 7 21:07:55 2006