note 43007 deleted from function.mktime by tomsommer

From: Date: Sun, 07 Nov 2004 20:28:05 +0000
Subject: note 43007 deleted from function.mktime by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-80243@lists.php.net to get a copy of this message
Note Submitter: foz at removethisbit dot foz dot me dot uk ---- <?php // My function for returning an age. e.g. 23 and 129 days function myAge($DOB) // YYYY-MM-DD { // Split $DOB $DOBArray = explode("-", $DOB); $DobYear = $DOBArray[0]; $DobMonth = $DOBArray[1]; $DobDay = $DOBArray[2]; // Get today's year, month and day $TodayDay = date('d'); $TodayMonth = date('m'); $TodayYear = date('Y'); // Work out Age in Years if (($TodayMonth > $DOBArray[1]) || (($TodayMonth == $DOBArray[1]) && ($TodayDay >= $DOBArray[2]))) { $AgeYear = $TodayYear - $DOBArray[0]; } else { $AgeYear = $TodayYear - $DOBArray[0] - 1; } // Calculate current "day of year" $dayofyear = date('z', mktime(0, 0, 0, date("m"), date("d"), date("Y"))); $dayofyear = $dayofyear+1; //Calculate birthday's "day of year" $dayofbday = date('z', mktime(0, 0, 0, $DobMonth, $DobDay, date("Y"))); if ($dayofbday > $dayofyear) { $days = 365 - ($dayofbday - $dayofyear); } else { $days = ($dayofyear - $dayofbday); } // return the age return $AgeYear . " and " . $days . " days"; } ?>

« previous php.notes (#80243) next »