Given two dates what is the best way of finding the number of weekdays in PHP?

前端 未结 4 1703
自闭症患者
自闭症患者 2021-01-24 08:53

The title is pretty much self explanatory. Given two dates what is the best way of finding the number of week days using PHP? Week days being Monday to Friday.

For insta

4条回答
  •  萌比男神i
    2021-01-24 09:51

    The best way is to iterate through all dates in between the given date range, and get the day of week for each date. If it's a week day, increment a certain counter. At the end of the process you get the number of weekdays.

    The PHP functions mktime() and date() (for working with UNIX timestamps) are your friends here.

提交回复
热议问题