Home / Web Development / HTML / Print all second saturday,fourth saturday and sunday between two date using php

Print all second saturday,fourth saturday and sunday between two date using php

Hi guys!
In previous article we discuss how to Calculate the number of Second Saturady, Fourth Saturday and Sunday Between Two dates in PHPIn this article share how to print or display the second saturday,fourth saturday and all sunday between two date range unsing php.

Consider from date and two date for performing this operations. The output is may be one element or more than one element. So we using the array for storing and printing the result.

Some important tips or points are used for finding the solutions. They are:

  • Calculating the week number for a given date – PHP
  • Day of the Date
  • Print second saturday, fourth saturdayand all sunday

Based on the above steps or points we can reach the solution. Because, we get the day of the date then we get the day is sunday or saturday. After that we can find day of the week. If the week is 2 then we can say it’s second week the we can find the second saturday.If the week is 4 then we can find the fourth saturday. And also we can find all sundays.

Calculating the week number for a given date – PHP

Getting the week number of given date in month using php. It’s very simple and useful for finding the second or fourth week between two date range. Its very useful for fetching all second saturday or fourth saturday from calender.

In the above code the output is:4. 22nd august is fourth week of 2017.

Day of the Date -PHP

The day of the date in php is check the date of the day. We can print all the day, between two date.

The output of the above code is:Thursday.

Print second saturday, fourth saturdayand all sunday

Fetch all second saturday,fourth saturday and all sunday between two date using pure php. Its very simple, because we get the day of the date, and also week of the date. If the week is 2 and day is saturday then we get the second saturday. Based on this method we get fouth saturday, sunday between the two date range.

Full Code

The output is:

total second saturday fourth saturday and sunday:10
[{“title”:”Second Saturday “,”start”:”2017-07-08″},{“title”:”Sunday”,”start”:”2017-07-09″},{“title”:”Sunday”,”start”:”2017-07-16″},{“title”:”Fourth Saturday “,”start”:”2017-07-22″},{“title”:”Sunday”,”start”:”2017-07-23″},{“title”:”Sunday”,”start”:”2017-07-30″},{“title”:”Sunday”,”start”:”2017-08-06″},{“title”:”Second Saturday “,”start”:”2017-08-12″},{“title”:”Sunday”,”start”:”2017-08-13″},{“title”:”Sunday”,”start”:”2017-08-20″}]

If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

Leave a Reply

Your email address will not be published. Required fields are marked *

Social Media Auto Publish Powered By : XYZScripts.com