How can the PHP code be modified to incorporate a time-based condition for displaying the next training date effectively?

To incorporate a time-based condition for displaying the next training date effectively, we can use PHP's date and time functions to compare the current date with the next training date. If the current date is past the next training date, we can calculate and display the next training date based on a predefined interval.

<?php
$currentDate = strtotime(date("Y-m-d"));
$nextTrainingDate = strtotime("2023-01-01"); // Example next training date

if ($currentDate > $nextTrainingDate) {
    $nextTrainingDate = strtotime("+1 month", $currentDate); // Display next training date in 1 month
}

echo "Next training date: " . date("Y-m-d", $nextTrainingDate);
?>