note 73056 added to function.mktime

From: Date: Wed, 07 Feb 2007 16:39:02 +0000
Subject: note 73056 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-123060@lists.php.net to get a copy of this message
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; ?> ---- Server IP: 64.71.164.2 Probable Submitter: 64.135.100.2 ---- Manual Page -- http://www.php.net/manual/en/function.mktime.php Edit -- https://master.php.net/note/edit/73056 Del: integrated -- https://master.php.net/note/delete/73056/integrated Del: useless -- https://master.php.net/note/delete/73056/useless Del: bad code -- https://master.php.net/note/delete/73056/bad+code Del: spam -- https://master.php.net/note/delete/73056/spam Del: non-english -- https://master.php.net/note/delete/73056/non-english Del: in docs -- https://master.php.net/note/delete/73056/in+docs Del: other reasons-- https://master.php.net/note/delete/73056 Reject -- https://master.php.net/note/reject/73056 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123060) next »