- Instant help with your Php coding problems

Get same day in the next week in PHP

Question:
How to get same day in the next week in PHP?
Answer:
$today = new DateTime();
$sameDayNextWeek = $today->add(new DateInterval('P1W'));

echo $sameDayNextWeek->format('Y-m-d');
Description:

To get the date one week from now, for example, if today is Tuesday then the next Tuesday use DateTime . First, create a DateTime object for the actual day. The add 1 week to it using the add method with the P1W  format string. Now your DateTime object will contain the next week's day and you can format the output as you want.

Share "How to get same day in the next week in PHP?"