Get all Work Days in a Week for a given date

后端 未结 5 1746
萌比男神i
萌比男神i 2020-12-06 14:58

So I have one date as a string:

2011/06/01

I need to get the 5 DateTime objects from it that correspond to the five weekdays (Monday to Fri

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-06 15:53

    You can get the number of the day in the week with date('w') 0 (for Sunday) through 6 (for Saturday). From this you can get the rest of the work days with strtotime("+1 DAY", [your timestamp]) and so on. When you've got the dates you can make the objects.

提交回复
热议问题