How can PHP be used to highlight upcoming events in red and past events in grey within an event list?
To highlight upcoming events in red and past events in grey within an event list, you can compare the event date with the current date using PHP. If the event date is in the future, apply a red color style to it, and if the event date is in the past, apply a grey color style to it.
<?php
$current_date = date('Y-m-d');
$event_date = '2022-12-31'; // Replace this with the actual event date
if ($event_date > $current_date) {
echo '<span style="color: red;">Upcoming Event</span>';
} else {
echo '<span style="color: grey;">Past Event</span>';
}
?>