Re: Re: strtotime
| From: | Tamara Temple | Date: | Sun, 17 Oct 2010 13:56:20 +0000 |
| Subject: | Re: Re: strtotime | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-308764@lists.php.net to get a copy of this message | ||
On Oct 17, 2010, at 12:58 AM, John Taylor-Johnston wrote:
According to this, I'm 44 not 45 :)p $birthday = '1965-08-30'; //calculate years of age (input string: YYYY-MM-DD) function birthday ($birthday){ list($year,$month,$day) = explode("-",$birthday); $year_diff = date("Y") - $year; $month_diff = date("m") - $month; $day_diff = date("d") - $day; if ($day_diff < 0 || $month_diff < 0)This will trigger anytime the current day of the month is less than 30.
$year_diff--;return $year_diff; } echo birthday ($birthday);