Reputation: 846
how to find date of last thursday of the month in php ?
it is for the payment thing. staffs needs to paid on last thursday of the month on which they have submitted invoices. I am having hard time finding out the date of last thursday of month
thanks abhinab
Upvotes: 2
Views: 2169
Reputation: 54659
PHP >= 5.3:
<?php
$date = strtotime('last thu of this month');
echo date('d.m.Y H:i:s', $date);
PHP < 5.3:
<?php
$date = strtotime(sprintf('+1 month %s %s', date('F'), date('Y')));
while (date('D', $date) !== 'Thu') {
$date -= 86400;
}
echo date('d.m.Y H:i:s', $date);
(didn't find a better way to do this)
Output:
30.06.2011 00:00:00
Upvotes: 2
Reputation: 158361
Upvotes: 0