I have problem in php find start date & end date of month & year , when i know the year and month ?
ex:
input - > year = 2011 , month = 08
output -> start date = 01 , end date = 31
Subtract Dates in Excel To find the number of dates between the start date and end date, use this formula in cell C2: =B2-A2.
Note: This formula =A2-WEEKDAY(A2,2)+1 will return Monday as the beginning of week based on the given date. Select a blank cell you will return the beginning of week, and enter the formula =A2-MOD(A2-2,7) (A2 is the cell with given date) into it, and then drag the Fill Handle to the range as you need.
echo date('m-01-Y 00:00:00',strtotime('this month')) . '<br/>';
echo date('m-t-Y 12:59:59',strtotime('this month')) . '<br/>';
Start date will always be 1 and you can find the end date with the following function.
cal_days_in_month(CAL_GREGORIAN, $month, $year);
reference:
cal_days_in_month ( int $calendar , int $month , int $year ) : int
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With