note 43007 added to function.mktime

From: Date: Sun, 06 Jun 2004 19:43:19 +0000
Subject: note 43007 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-70710@lists.php.net to get a copy of this message
<?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"; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.mktime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43007 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43007&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43007&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70710) next »