PHP cal_days_in_month Function: Returns Number of Days in a Month for a Given Calendar

The article explains PHP's cal_days_in_month function, detailing its purpose, parameters (calendar, month, year), return value, and provides a complete example showing how to retrieve and display the number of days in a specific month of a given year.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
PHP cal_days_in_month Function: Returns Number of Days in a Month for a Given Calendar

The cal_days_in_month function in PHP returns the number of days in a specific month of a given year according to a specified calendar.

Parameters

calendar : The calendar system to use (e.g., CAL_GREGORIAN).

month : The month number (1‑12) within the chosen calendar.

year : The year number within the chosen calendar.

Return value : An integer representing the number of days in the specified month.

Example

<?php
$num = cal_days_in_month(CAL_GREGORIAN, 8, 2003);
// 31
echo "There was $num days in August 2003";
?>
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendPHPfunctionCalendarexampledate
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.