2nd and 4th Saturday of the month

Find the second and fourth Saturday

DateTimeImmutable can express nth-weekday rules directly, which avoids manual weekday-offset arithmetic.

$secondSaturday = new DateTimeImmutable('second saturday of September 2026');
$fourthSaturday = new DateTimeImmutable('fourth saturday of September 2026');

echo $secondSaturday->format('Y-m-d') . "<br>";
echo $fourthSaturday->format('Y-m-d');

This current example appears first; the detailed examples below are retained and modernized for comparison and additional use cases.

2nd Saturday for the Month:09 of Year:2026 :12-09-2026
4th Saturday for the Month:09 of Year:2026 :26-09-2026
3rd Wednesday for the Month:09 of Year:2026 :16-09-2026
By default, current month is used , you can change the below code to any month and year.
$year=date('Y');  // Change the value to use different Year
$month=date('m'); // Change the value to use different month
//$month=9;
$firstday = new  DateTime("$year-$month-1 0:0:0");
$first_w=$firstday->format('w'); // weekday of firstday 
$saturday1=new DateTime;
$saturday1->setDate($year,$month,14-$first_w);
echo "2nd Saturday for the Month:
	$month of Year:$year :".$saturday1->format('d-m-Y');
To display 4th Satruday, add this code at the end.
$saturday2=new DateTime;
$saturday2->setDate($year,$month,28-$first_w);
echo "4th Saturday for the Month:
	$month of Year:$year :".$saturday2->format('d-m-Y');
To display 3rd Wednesday , add this code at the end.
$wednesday3=new DateTime;
$wednesday3->setDate($year,$month,18-$first_w);
echo "3rd wednesday for the Month:
		$month of Year:$year :".$wednesday3->format('d-m-Y');	

Formula for any day any week

day_number: For Sunday use 1, Monday=2, ... and for Saturday use 7

my_number=day_number + (Week_number-1)*7
By using above formula we can get the number and same can be used for getting the date of any week with weekday of the month.

To get 3rd Wednesday ( day_number = 4 ) Week_number=3
my_number=4 + (3-1)*7;
$wednesday3->setDate($year,$month,my_number-$first_w);
Try for other days of the week.
PHP Date Functions Displaying calendar for selection of date by user


Subscribe to our YouTube Channel here



plus2net.com







03-03-2020

Thanks for providing this simple and efficient 2nd and 4th Saturday of the month. It works !

04-03-2020

The script is generalized and it can be used to find out any weekday of any week.




PHP video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer