this show the next Saturday
<?php echo date("l,j M Y", strtotime("next saturday")); ?>
i.e Saturday,23 July 2011.
I want to show also the next next Saturday that is Saturday 30 july 2011 and so on
$next_saturday = strtotime("next saturday");
$the_saturday_after_that = strtotime("next saturday", $next_saturday);
...and so on.
With PHP 5.2+, you can use DateTime
and DateInterval
to get the next 3 Saturdays:
Example:
<?php
$date = new DateTime('next saturday');
// Loop 3 times.
for ( $i = 0; $i < 3; $i++ )
{
echo $date->format('Y-m-d') . PHP_EOL;
// Add 1 month.
$date->add(new DateInterval('P7D'));
}
Alternatively,
strtotime("next saturday + 1 week")
strtotime("next saturday + 2 weeks")
...
strtotime("next saturday + $weeks week")
Example with \DateTime:
/**
* Get next three saturday
*
* @return \DateTime[]
*/
function getNextThreeSaturday()
{
$count = 3;
$current = new \DateTime('saturday this week');
$results = [];
for ($i = 0; $i < $count; $i++) {
$results[] = clone $current->modify('next saturday');
}
return $results;
}