what is wrong with the code, the first half is working correctly the second half is partly correct only the last date ie 31 is displayed incorrectly. as follows:
2023 2024 2025
01-4-2024 - 31-4-2024
01-5-2024 - 31-5-2024
01-6-2024 - 31-6-2024
01-7-2024 - 31-7-2024
01-8-2024 - 31-8-2024
01-9-2024 - 31-9-2024
01-10-2024 - 31-10-2024
01-11-2024 - 31-11-2024
01-12-2024 - 31-12-2024
01-1-2024 - 31-1-2024
01-2-2024 - 31-2-2024
01-3-2024 - 31-3-2024
$year=date("Y");
$data=array(4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3);
echo "<table><th>".$previous=date("Y",strtotime('-1 year')) ."</th><br>";
echo "<th>".$year=date("Y")."</th><br>";
echo "<th>".$future=date("Y",strtotime('+1 year')) ."</th><br></table>";
foreach ($data as $months) {
$start_date= date("01-$months-$year");
echo $start_date;
echo date("t-$months-$year",strtotime("last day of this $months"));
echo "<br>";
}
?>