How can PHP be utilized to calculate and display recurring event dates based on user input?

To calculate and display recurring event dates based on user input in PHP, you can use the DateTime class along with a loop to iterate through the desired number of occurrences. You can prompt the user for input such as the start date, interval, and number of occurrences, and then calculate the recurring dates accordingly.

<?php
// Get user input for start date, interval, and number of occurrences
$start_date = new DateTime($_POST['start_date']);
$interval = new DateInterval('P' . $_POST['interval'] . 'D');
$occurrences = $_POST['occurrences'];

// Display the start date
echo "Start Date: " . $start_date->format('Y-m-d') . "<br>";

// Calculate and display recurring event dates
for ($i = 1; $i <= $occurrences; $i++) {
    $start_date->add($interval);
    echo "Occurrence " . $i . ": " . $start_date->format('Y-m-d') . "<br>";
}
?>