Estoy trabajando en un tipo de función de repetición del calendario de Google usando angularjs/php. 
Intente repetir el evento cada 2 semanas en una selección múltiple de días y ese evento se repetirá hasta 3 veces (veces) desde la fecha de inicio. PFA mi código.
$scope.daysarr = [{dayname: "SUN",Name: 'Sunday', Selected: true}, {dayname: "MON",Name: 'Monday', Selected: false}, {dayname: "TUE",Name: 'Tuesday', Selected: true}, {dayname: "WED",Name: 'Wednesday', Selected: false}, {dayname: "THU",Name: 'Thursday', Selected: true}, {dayname: "FRI",Name: 'Friday', Selected: false}, {dayname: "SAT",Name: 'Saturday', Selected: false}]; for ($i=1; $i<=$after_occurance ; $i++) { // 3times if($i==1) { $datesArr[] = $date->format('Ym-d'); } else { echo $dayOfWeek = $date->format('l'); if ($dayOfWeek == 'Sunday' && $daysarr[0]->selected==1) { // i want to loop sun,tue,thu $date->modify("+{$repeatnum} weeks"); // 2 weeks $datesArr[] = $date->format('Ym-d'); } if ($dayOfWeek == 'Tuesday' && $daysarr[2]->selected==1) { // i want to loop sun,tue,thu $date->modify("+{$repeatnum} weeks"); // 2 weeks $datesArr[] = $date->format('Ym-d'); } if ($dayOfWeek == 'Thursday' && $daysarr[4]->selected==1) { // i want to loop sun,tue,thu $date->modify("+{$repeatnum} weeks"); // 2 weeks $datesArr[] = $date->format('Ym-d'); } }}Obtener la salida solo la fecha de inicio seleccionada en repetición en lugar de los días seleccionados
Rendimiento esperado:
dom: 09-ene-2022, 23-ene-2022, 06-feb-2022
mar: 04-ene-2022, 18-ene-2022, 01-feb-2022
jue: 06-ene-2022, 20-ene-2022, 03-feb-2022
Lo haría usando segundos según la fecha de inicio proporcionada convertida a EPOCH:
<?php // convert startDate input to epoch time $startDate = strtotime($_POST['startDate']); // how many seconds does 2 weeks contain? $interval = 2 * 7 * 24 * 60 * 60; // calculate and display the startDate, followed by its next ocurrences for ($i=0; $i<$after_occurance; $i++) { // 3times if ($i == 0) { // output the first date with the Day name echo date("D, dmY", ($startDate + ($i * $interval))); } else { // all other dates won't display the day name echo date("dmY", ($startDate + ($i * $interval))); } // if not last, add a comma and a space to the output if ($i < $after_occurance-1) { echo ', '; } else { echo '<br/>'; } }