Forum Moderators: coopster

Message Too Old, No Replies

Using string variables in mktime

         

lbombardier

9:44 pm on Apr 23, 2009 (gmt 0)

10+ Year Member



I'm posting a date to a php script and then trying to return dates in the future at two week intervals. This is for a recurring event in a calendar.

I can get it working at 1 week intervals but the variable I'm using to add to the various days does not evaluate. Here's what I have so far:

$pieces = explode('-', $_POST['myDate']);
for($i=1; $i < 5; $i++)
{
$days = $i * 7;
$interval[$days] = mktime(0, 0, 0, $pieces[0], $pieces[1] + $days, $pieces[2]);
}

When i print the array,

foreach($interval as $key => $value)

I get 1 week increments like this (Based on posting April 1):

7 - 04 08 2009

14 - 04 15 2009

21 - 04 22 2009

28 - 04 29 2009

Clearly the $days value is the correct number, does anyone now how to get mktime() to evaluate it appropriately?

lbombardier

10:44 pm on Apr 23, 2009 (gmt 0)

10+ Year Member



Dumbest post ever. My bad.

I think I spent too much time staring at various versions of the code ...didn't realize that it totally works as expected.

Change the 7 to 14 et voila.

coopster

4:46 pm on Apr 24, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



or 7 * 2 ;)
I must admit, you made me laugh out loud.