Calculating date differences using mktime
| From: | kris at grinz dot com | Date: | Tue, 07 Nov 2000 18:59:56 +0000 |
| Subject: | Calculating date differences using mktime | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-24154@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to figure out how to get this code I wrote to work. There
is something simple that I am not apparently grasping. Basically, I
have $now and $then, variables computed using mktime. $now is
today's date and $then is the calendar date 90 days from $now.
What I want to do is have output which reads "There are $x Months
$y Days between $now and $then". I've found a bit of info online
about similar stuff.. but nothing exactly like this. I tried DateDiff
from phpbuilder with no success. Can someone educate me briefly
on this matter to help me figure out what I'm missing? Code is
below... Thanks, Kris
<?php
$year=date(Y, time());
$month=date(m, time());
$today=date(j, time());
$now=mktime(0,0,0,$month,$today,$year);
$then=mktime(0,0,0,$month,$today+90,$year);
//insert computation code that I am clueless on
echo"There are $x Months and $y Days between $now and $then";
?>