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.
Reference:
PHP DateInterval reference
Share "How to get same day in the next week in PHP?"
Related snippets:
- Add minutes to date time in PHP
- Add days to date in PHP
- Get same day in the next week in PHP
- Get time difference in minutes in PHP
- Convert date to timestamp in PHP
- Convert timestamp to DateTime in PHP
- Get the last day of a month from date in PHP
- Get the number of days between two dates in PHP
- Get yesterday's date in PHP
- Get tomorrow's date in PHP
- Get current time in PHP
- Get actual date in PHP
Tags:
same day next week, next week day, one week from now Technical term:
Get same day in the next week in PHP