note 74341 deleted from function.date by bobby

From: Date: Fri, 06 Apr 2007 14:41:58 +0000
Subject: note 74341 deleted from function.date by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-125146@lists.php.net to get a copy of this message
Note Submitter: dimimo at NO2SPAM dot gmail dot com ---- A simple function to know the AGE of somebody. The only issue is there is a the time difference between the server and the client on the day of his or her birthday: When no date is given, '--' will be returned. The $date should be given into the mySQL "YYYY-mm-dd" format. function age($date) { if ($date == '0000-00-00' || empty($date)) return '--'; $day = substr($date,8,2); $month = substr($date,5,2); $year = substr($date,0,4); $age = date("Y") - $year; if ($month > date("m")) --$age; elseif ($month == date("m") && $day > date("d")) --$age; return $age; } That's it!

« previous php.notes (#125146) next »