To get the next Saturday’s date in PHP, you can use the strtotime
function with an appropriate string format. Here’s an example:
$nextSaturday = strtotime('next Saturday');
echo date('Y-m-d', $nextSaturday);
This code:
- Uses
strtotime('next Saturday')
to get the timestamp of the next Saturday. - Converts it into a date format with
date('Y-m-d', $nextSaturday)
.
Thus, you’ll get the next Saturday’s date in the YYYY-MM-DD
format.