Reputation: 55
I found the next Wednesday which is January 2, and I need to print Thursday(January-3). I used the same method to find the next Thursday, but I am getting 27th of December which is also Thursday. how to use '+1' day in this senario.
$f_date = new DateTime();
$f_date->modify('next wednesday');
$s_date = new DateTime();
$s_date->modify('next thursday');
I tried something like this. but it doesn't work
date(strtotime($f_date->modify('next wednesday')->date .' +1 day'))->format('F d');
Upvotes: 0
Views: 74
Reputation: 349
You can do something like this:
$f_date = new DateTime();
$f_date = $f_date->modify('next wednesday');
$f_date->modify('+1 day');
Now, you can apply your desired formats
Upvotes: 0
Reputation: 147166
Your code is almost right, you just need to call modify()
again:
$f_date = new DateTime();
$f_date->modify('next wednesday')->modify('+1 day');
echo $f_date->format('F d');
Output:
January 03
Upvotes: 3
Reputation: 191
You can use following to return January 3
echo date('F d',strtotime('today'. ' +8 day'));
Upvotes: -1