What are the best practices for handling date calculations in PHP, especially when determining the number of days in a month?

When handling date calculations in PHP, especially when determining the number of days in a month, it's important to consider leap years and varying month lengths. One common approach is to use the `cal_days_in_month()` function in PHP, which returns the number of days in a month for a specified year and month.

// Get the number of days in a specific month and year
$month = 2; // February
$year = 2022;
$days_in_month = cal_days_in_month(CAL_GREGORIAN, $month, $year);

echo "There are $days_in_month days in the month of February $year.";