You are here: Re: How do you get someone's age from DOB? « PHP Programming Language « IT news, forums, messages
Re: How do you get someone's age from DOB?

Posted by Justin Koivisto on 01/30/06 21:44

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация