What functions can be used to handle time calculations in PHP?

When working with time calculations in PHP, you can use various built-in functions to manipulate dates and times. Some commonly used functions include date(), strtotime(), time(), and mktime(). These functions allow you to format dates, calculate time differences, add or subtract time intervals, and perform various other time-related operations.

// Example: Calculating the difference between two dates
$date1 = strtotime('2021-01-01');
$date2 = strtotime('2021-12-31');

$diff = $date2 - $date1;
$days_difference = floor($diff / (60 * 60 * 24));

echo "The difference between the two dates is $days_difference days.";