Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

work out the date of the fourth saturday in the current month

Tags:

date

php

datetime

Bit stuck about how to go about this one. Given the current month, I need to to return the date of the fourth saturday of each month.

e.g. This month would be Feb 20th, next would be March 27th.

Thanks

like image 726
Tom Avatar asked Feb 13 '09 16:02

Tom


1 Answers

I'm not a PHP coder, however, it seems strtotime is what you're after.

You can use strtotime("fourth Saturday") and it will return the 4th saturday.

Check out the strtotime docs.

EDIT:

Just to make the answer complete, thanks to Tom and Paul Dixon

date('dS F',strtotime('Fourth Saturday '.date('F o'))); 
like image 82
Robin Day Avatar answered Oct 11 '22 14:10

Robin Day