I have a period with startdate of 2016-12-26
and end date 2017-03-04
.
Now I would like to find out how many days in each months there is, from a given period. Expected output from the above period dates (array):
2016-12: 5
2017-01: 31
2017-02: 28
2017-03: 4
How can I accomplish this cleanest way? I have tried to:
- first looking at the period_start, get the days = 26 and
- find out the start/end dates of the months between 2016-12 and 2017-03, to then calculate the days here (31 respectively 28 in february)
- then finally calculating the 4 days in 2017-03.
But is there any cleaner/better way?