Estoy intentando muchos enfoques pero luego me quedo a medio camino.PHP. ¿Cómo obtener un evento bimensual recurrente?
Digamos que la orden fue creada hoy. Necesito mostrar cuándo ocurrirá la próxima orden recurrente. Así que tengo el pedido creado el 13 de junio de 2012. Luego he establecido el calendario en orden recurrente bimestral, cada 1er mes. ¿Cómo calcular cuándo se producirá la próxima orden recurrente? La respuesta es el 1 de agosto.
Si alguien puede delinear un enfoque, sería muy útil, no tiene que ser código. Esto es lo que tengo hasta ahora ...
// 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<=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.'<br />';
$months[] = $add_month;
}
echo '<pre>';
print_r($months);
echo '</pre>';
no quiero simplemente encontrar lo que es la fecha en dos meses a partir de ahora. Digamos orden creado el 1 de junio. El próximo pedido recurrente es el 1 de agosto. Entonces digamos ahora, hoy es el 1 de septiembre, pero el próximo pedido recurrente es el 1 de octubre. Ver mi dilema?
¿Desea ** solo ** la próxima fecha recurrente a partir de hoy, o todas las fechas recurrentes desde la creación hasta la siguiente inclusive desde hoy? – salathe
No veo tu dilema. ¿Por qué importa el 1 de septiembre? ¿Cómo se relaciona con el problema de orden recurrente? – afuzzyllama
Porque si el pedido se creó hoy el 13 de junio, es fácil obtener el siguiente pedido recurrente. También es fácil crear una variedad de las siguientes 6 órdenes recurrentes. Ahora, si hoy fuera el 1 de septiembre, ¿cómo se calcula la próxima orden recurrente? Todo lo que se debe calcular es UNA fecha, solo el siguiente orden recurrente. – leonel