note 58561 deleted from function.mktime by derick

From: Date: Sun, 24 Sep 2006 11:52:26 +0000
Subject: note 58561 deleted from function.mktime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117502@lists.php.net to get a copy of this message
Note Submitter: mickyfunk at hotmail dot com ---- <? /* This program work out the difference between 2 dates one been the current date and the is set by changing the numbers in $pastdate. This could easily be configured to accept input from a form.*/ //this sets the variable $today to todays date $today = date("d/m/Y"); //this sets the variable $birthday to the date selected $pastdate = date("18/11/1983"); //this seperates the $today into an array $explodetoday = explode("/", $today); //this makes a timestamp out of the exploded date this number is in seconds $stoday = mktime(0, 0, 0, $explodetoday[1], $explodetoday[0], $explodetoday[2]); $explodepastdate = explode("/", $pastdate); $spastdate = mktime(0, 0, 0, $explodepastdate[1], $explodepastdate[0], $explodepastdate[2]); //this works out the difference between today and the date set. $sDifference = $stoday - $spastdate; //this works out the age of the person in years $yDifference = ($sDifference / 60 / 60 / 24 / 365.25); $yDifferences = number_format($yDifference, 2); echo("$yDifferences Years Old\n"); ?> Not as good as some others but this is the first real bit of code i have created.

« previous php.notes (#117502) next »