How can the current time be retrieved and compared with predefined time intervals in PHP to determine which content to display?

To retrieve the current time in PHP, you can use the `date()` function with the desired format. To compare the current time with predefined time intervals, you can use the `strtotime()` function to convert the predefined times to timestamps and then compare them with the current timestamp. Based on the comparison result, you can determine which content to display.

$current_time = time(); // Get current timestamp
$predefined_start = strtotime('08:00:00'); // Convert predefined start time to timestamp
$predefined_end = strtotime('17:00:00'); // Convert predefined end time to timestamp

if ($current_time >= $predefined_start && $current_time <= $predefined_end) {
    // Display content for specified time interval
    echo "Display content for business hours";
} else {
    // Display content for outside business hours
    echo "Display content for after hours";
}