note 74341 added to function.date

From: Date: Fri, 06 Apr 2007 12:16:53 +0000
Subject: note 74341 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-125143@lists.php.net to get a copy of this message
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! ---- Server IP: 193.190.198.20 Probable Submitter: 81.245.243.151 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/74341 Del: integrated -- https://master.php.net/note/delete/74341/integrated Del: useless -- https://master.php.net/note/delete/74341/useless Del: bad code -- https://master.php.net/note/delete/74341/bad+code Del: spam -- https://master.php.net/note/delete/74341/spam Del: non-english -- https://master.php.net/note/delete/74341/non-english Del: in docs -- https://master.php.net/note/delete/74341/in+docs Del: other reasons-- https://master.php.net/note/delete/74341 Reject -- https://master.php.net/note/reject/74341 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125143) next »