Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP. How to get a bimonthly recurring event?
    primarykey
    data
    text
    <p>I'm trying many approaches but then I get stuck half way.</p> <p>Let's say order was created today. I need to display when the next recurring order will happen. So I have order created June 13, 2012. Then I have set the schedule to bimonthly recurring order, every 1st of month. How to calculate when the next recurring order will happen? The answer is August 1st.</p> <p>If someone can outline an approach it would be very useful, it doesn't have to be code. This is what I have so far...</p> <pre><code> // first, get starting date $start_date_month = date('m', strtotime($start_date)); // get this year $this_year = date('Y'); // if this month is december, next month is january $this_month = date('m', $timestamp_month); if($this_month == 12){ $next_month = 1; // if this month is not december add 1 to get next month }else{ $next_month = $this_month + 1; } // get array of months where recurring orders will happen $months = array(); for ($i=1; $i&lt;=6; $i++) { $add_month = $start_date_month+(2*$i); // 2, 4, 6, 8, 10, 12 if($add_month == 13){$add_month = 1;$year = $this_year+1;} elseif($add_month == 14){$add_month = 2;$year = $this_year+1;} elseif($add_month == 15){$add_month = 3;$year = $this_year+1;} elseif($add_month == 16){$add_month = 4;$year = $this_year+1;} elseif($add_month == 17){$add_month = 5;$year = $this_year+1;} elseif($add_month == 18){$add_month = 6;$year = $this_year+1;} elseif($add_month == 19){$add_month = 7;$year = $this_year+1;} elseif($add_month == 20){$add_month = 8;$year = $this_year+1;} else{$year = $this_year;} echo $what_day.'-'.$add_month.'-'.$year.'&lt;br /&gt;'; $months[] = $add_month; } echo '&lt;pre&gt;'; print_r($months); echo '&lt;/pre&gt;'; </code></pre> <p><strong>I don't want to simply find what's the date in two months from now. Let's say order created June 1. Next recurring order is August 1. Then let's say now, today is September 1st, but next recurring order is October 1st. See my dilemma?</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload