Question:
I need a schedule for an agenda that gives me the date of the next Mondays from a certain date
Ex: today is the 01/06th I need to know what day the next 10 Mondays will fall.
1 = 05/06/2017
2 = 12/06/2017
3 = 19/06/2017
4 = 26/06/2017
5 = 03/07/2017
6 = 10/07/2017
8 = 17/07/2017
9 = 24/07/2017
10= 31/07/2017
My problem is knowing what the next Monday is from a certain date, because the next ones will be easier and just add the 7 days
Answer:
Here is the example code for the next Monday from a date:
$dia = new DateTime( '2017-06-01' );
$dia->modify( 'next monday' );
echo $dia->format('d/m/Y'); // 05/06/2017
Get the next 10 seconds in an array starting from the next second taking the current day as a reference:
$dia = new DateTime();
$dia->modify( 'next monday' );
$nextMondaysNeed = range(1,10);
$nextMondaysArray = array($dia->format('Y-m-d'));
foreach($nextMondaysNeed as $number)
{
$nextMondaysArray[] = $dia->modify('+7 day')->format('Y-m-d');
}
print_r($nextMondaysArray);