Reputation: 143
I need to display the date of Tuesday for this week, next week, and the week after that.
For example,
$first_date = date('m/d/y',strtotime('tuesday this week')); =>result => '01/10/13'
$second_date = date('m/d/y',strtotime('tuesday next week')); =>result => '08/10/13'
$third_date = -----This one i needed-------- =>result => '15/10/13'
Upvotes: 1
Views: 4847
Reputation: 1557
$third_date = date('m/d/y', strtotime($second_date . ' + 7 days'));
Based on the fact that $second_date is on a tuesday, then second date plus 7 days will be also on a tuesday.
Upvotes: 0
Reputation: 18430
The third Tuesday from Tuesday this week can be found like this:-
$date = new \DateTime();
$date->setISODate($date->format('o'), $date->format('W'), 2);
$date->add(new \DateInterval('P3W'));
Although it isn't 100% clear that that is what you want.
Upvotes: 1
Reputation: 3163
Try this:
$third_date = date('m/d/y',strtotime('tuesday +2 week'));
Online example:
http://sandbox.onlinephpfunctions.com/code/bd9189f69add69490cb0254c23ada04a24355338
Upvotes: 2