Loop over the twelve months and calculate each month independently.
$year = 2027;
for ($month = 1; $month <= 12; $month++) {
$days = cal_days_in_month(CAL_GREGORIAN, $month, $year);
echo $month . ': ' . $days . "<br>";
}for ($m = 1; $m <= 12; $m++) {
$dateObject = DateTimeImmutable::createFromFormat('!m', (string) $m);
$monthName = $dateObject->format('F'); // Month name
}
This value will use as Month and display the calendar by using the month value. $year=2027; // change this to another year
Now we are reading month value from for loop and year directly so in this script we have removed the dropdown selection box for month and year.
if(($row % 3)== 0){
echo "</tr><tr>";
}
In the above code we check the modulus of value of $month % 3 and if it is equal to zero then it will add one row. You can change this value ( from 3 ) to any other value to display that many calendars in a row.
.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
| paul | 20-12-2014 |
| how can i make the week start on a Monday? | |
| smo | 21-12-2014 |
| Two lines are to be added and the Header row is to be changed. This part is added to main calendar tutorial showing monthly calendar now. Inside your zip file one new calendar ( cal3.php ) is added which shows week starting from Mondays. | |