php - Get dates for specific weekdays
Get the solution ↓↓↓Solution:
One liner:
print date('Y-m-d H:i:s', strtotime('wednesday this week 22:59:00'));¸
Yields:2016-01-27 22:59:00
Answer
Solution:
How about
$wednesday = strtotime('wednesday this week');
$wednesdayStart = $wednesday - ($wednesday % 60*60*24);
$wednesdayEnd = $wednesdayStart + (60 * 60 * 24) - 1;
Answer
Solution:
You could use DateTime and do something like this.
$date = new \DateTime();
$date->setISODate((int)$date->format('o'), (int)$date->format('W'), 3);
$date->setTime(22, 59, 0);
echo $date->format('D d-m-Y H:i:s');
Demo.
Or, if you like one liners.
$date = (new \DateTime())->modify('wednesday this week')->setTime(22, 59, 0);
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the payload is invalid.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.