datetime to date day of month of year php code example
Example 1: in date function + 1 month and - 1 day in php
echo Date("Y-m-d", strtotime("2013-01-01 +1 Month -1 Day"));
echo Date("Y-m-d", strtotime("2013-01-31 +1 Month -3 Day"));
echo Date("Y-m-d", strtotime("2013-01-31 +2 Month"));
echo Date("Y-m-d", strtotime("2013-01-31 +3 Month -1 Day"));
echo Date("Y-m-d", strtotime("2013-12-31 -1 Month -1 Day"));
echo Date("Y-m-d", strtotime("2013-12-31 -2 Month"));
echo Date("Y-m-d", strtotime("2013-12-31 -3 Month"));
echo Date("Y-m-d", strtotime("2013-12-31 -3 Month -1 Day"));
Example 2: php days in month
echo cal_days_in_month(CAL_GREGORIAN, 1, 2021);
echo date('t');