note 51117 added to function.date

From: Date: Sun, 20 Mar 2005 16:57:21 +0000
Subject: note 51117 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-86719@lists.php.net to get a copy of this message
A little function who calculate people age with their date of birth. The format of date used is the one used in mysql table. (For example: 2004-10-23) <?php function CalcAge($date_of_birth) { // YYYY-MM-DD $cur_year=date("Y"); $cur_month=date("m"); $cur_day=date("d"); $dob_year=substr($date_of_birth, 0, 4); $dob_month=substr($date_of_birth, 5, 2); $dob_day=substr($date_of_birth, 8, 2); if($cur_month>$dob_month || ($dob_month==$cur_month && $cur_day>=$dob_day) ) return $cur_year-$dob_year; else return $cur_year-$dob_year-1; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51117 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51117&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51117&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51117&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51117&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51117&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51117&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86719) next »