Re: Age
| From: | Edward van Bilderbeek - Bean IT | Date: | Sat, 09 Feb 2002 19:54:53 +0000 |
| Subject: | Re: Age | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-84127@lists.php.net to get a copy of this message | ||
don't know if there is some "date_diff" -like function, but you can do it
this way:
$now = getdate();
$nw_year = $now["year"];
$nw_month = $now["mon"];
$nw_day = $now["mday"];
$chk_date = "09/02/1977";
list ($chk_day, $chk_month, $chk_year) = explode("/", $chk_date);
print $nw_year;
$age = $nw_year - $chk_year;
if ($nw_month<$chk_month) $age--;
if ($nw_month==$chk_month && $nw_day<$chkday) $age--;
print "<BR>age: ".$age;
assuming that the date : "dd/mm/yyyy"
greets,
edward
----- Original Message -----
From: "André Felix Miertschink" <a.f.miertschink@terra.com.br>
To: <php-general@lists.php.net>
Sent: Saturday, February 09, 2002 8:08 PM
Subject: [PHP] Age
> Could anybody find out the simplest method of calculating the age?
> The date of birth is in the format string ('01/01/1977').
>
> André
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>