note 58561 added to function.mktime

From: Date: Tue, 08 Nov 2005 09:26:06 +0000
Subject: note 58561 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-98240@lists.php.net to get a copy of this message
<? /* 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. ---- Manual Page -- http://www.php.net/manual/en/function.mktime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58561 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58561&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58561&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58561&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58561&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58561&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58561&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58561&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58561&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#98240) next »