Re: strtotime

From: Date: Sun, 17 Oct 2010 05:58:14 +0000
Subject: Re: strtotime
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-308759@lists.php.net to get a copy of this message
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)
      $year_diff--;
    return $year_diff;
} echo birthday ($birthday); John Taylor-Johnston wrote:
I'm working my way right now through the manual: http://ca.php.net/manual/en/function.strtotime.php.


« previous php.general (#308759) next »