note 73056 deleted from function.mktime by nlopess

From: Date: Wed, 07 Feb 2007 20:04:18 +0000
Subject: note 73056 deleted from function.mktime by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123069@lists.php.net to get a copy of this message
Note Submitter: geekyboy at geekyboy dot com ---- I needed to calculate the difference, in days, between two days and could not find a quick example. So here is what I did: <?php $expire = ‘2006-02-07′; // could be a result from a database, or whatever // split the expire date into pieces $year = substr($expire, 0, 4); $month = substr($expire, 5, 2); $day = substr($expire, 8, 2); // build UNIX time out of todays date, and the expiration date $splitExpire = (mktime(0, 0, 0, $month, $day, $year)); $today = (mktime(0, 0, 0, date(’m'), date(’d'), date(’Y'))); // calculate the difference, and convert it to days $difference = (($today) - ($splitExpire)); $convertedToDays = ($difference/86400); echo $convertedToDays; ?>

« previous php.notes (#123069) next »