Is there any way in PHP to find out the last Wednesday of the current month? (or any day of the week for that matter)

For instance, the last Wednesday of this month (February 2014) is February 26, 2014

I know this would echo "February 2014"

echo date( 'F Y', strtotime( 'this month'));

This is my pseudo-code that doesn't work (it echoes "31 December 1969"):

echo date( 'd F Y', strtotime( 'last wednesday of this month'));

Any way to make this happen?

有帮助吗?

解决方案

$tsLast = strtotime( date('Y-m-01', strtotime('next month')).' last wednesday');
echo date(DATE_RFC850, $tsLast);

其他提示

This seems to work:

  $nextMonthStart = mktime(0,0,0,date('m')+1,1,date('Y'));
  $last_wednesday = date("d F Y",strtotime("previous wednesday", $nextMonthStart)); 
  echo $last_wednesday;

got it from here: How do I find what day the last saturday of the current month is in PHP?

echo Date('Y-m-d',strtotime('last Wednesday of F'));

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top