|
Posted by Hendri Kurniawan on 03/07/07 03:43
_Skare_Krow_ wrote:
> In my script main_date = 2007-01-24
> and I'm getting this as my result for the due date 2007 04 06
> what am I doing wrong here?
>
> Aaron
>
> <?
> $maint_date = date(' Y m d', $maint_date);
> if ($maint_interv = "monthly")
> {
> $interval = //mktime(0, 0, 0, date("m")+ 1, 1, date("Y"));
> "1 week";
> }
> $interval = strtotime($interval);
> $due_date = $maint_date + $interval;
> echo date(' Y m d', $due_date);
> echo "<br>$interval";
> ?>
do not put this line on:
$maint_date = date(' Y m d', $maint_date);
instead if $maint_date is a string "2007-01-24", do this:
$maint_date = strtotime($maint_date);
remove the reference to interval.
How to calculate interval:
"monthly": interval is 60 sec * 60 minutes * 24 hours * 30 days
so that is: $interval = 60 * 60 * 24 * 30;
assuming 1 month is 30 days of course.
So $due_date is simply $maint_date + $interval
[Back to original message]
|