note 22088 added to function.date

From: Date: Thu, 06 Jun 2002 07:10:18 +0000
Subject: note 22088 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-31522@lists.php.net to get a copy of this message
A simple php script with no java or vbscript to compare a date field from a mysql database to the current date. In this case the date for comparison is $birthday (YYYY-MM-DD) and the output is $age... <?php $today = getdate(); $month = $today['mon']; $day = $today['mday']; $year = $today['year']; list ($byear, $bmonth, $bday) = split ('-', $birthday); $rawage = $year-$byear; if ($month < $bmonth) {$age = $rawage-1;} elseif ($month == $bmonth AND $day < $bday) {$age = $rawage-1;} elseif ($byear == 0) {$age = "Unknown";} else {$age = $rawage;} ?> -- http://www.php.net/manual/en/function.date.php http://master.php.net/manage/user-notes.php?action=edit+22088 http://master.php.net/manage/user-notes.php?action=delete+22088 http://master.php.net/manage/user-notes.php?action=reject+22088

« previous php.notes (#31522) next »