Re: How do you get someone's age from DOB?
- From: Justin Koivisto <justin@xxxxxxxxx>
- Date: Mon, 30 Jan 2006 13:44:33 -0600
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@xxxxxxxxx
http://koivi.com
.
- Follow-Ups:
- Re: How do you get someone's age from DOB?
- From: comp.lang.php
- Re: How do you get someone's age from DOB?
- References:
- How do you get someone's age from DOB?
- From: comp.lang.php
- How do you get someone's age from DOB?
- Prev by Date: Re: Newbie needs a workaround - No Cron Jobs on Godaddy shared server!
- Next by Date: Which installer is better?
- 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
|