hier wieder ein Code Schnipsel überarbeitet von Chat GPT
<?php
// Set the timezone to use the default timezone
date_default_timezone_set(date_default_timezone_get());
// Load the RSS feed into a DOMDocument object
$rss = new DOMDocument();
$rss->load('https://urltorssfeed.de/rss');
// Create an array to hold the feed items
$feed = array();
// Loop through each item in the feed
foreach ($rss->getElementsByTagName('item') as $node) {
// Extract the title, description, link, and publication date
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'description' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
// Add the item to the array
array_push($feed, $item);
}
// Set the limit for the number of items to display
$limit = 10;
// Loop through each item up to the limit
for($x=0; $x<$limit; $x++) {
// Extract the title, link, and description from the item
$title = $feed[$x]['title'];
$link = $feed[$x]['link'];
$description = $feed[$x]['description'];
$current_date = date('Y-m-d'); // Aktuelles Datum im Format 'Y-m-d' speichern
$feed_date = date('Y-m-d', strtotime($feed[$x]['date'])); // Datum aus dem Feed im Format 'Y-m-d' speichern
if ($feed_date == $current_date) {
// Wenn das Datum aus dem Feed dem aktuellen Datum entspricht
echo '<span style="color: green;">•</span>';
} else if ($feed_date == date('Y-m-d', strtotime('-1 day', strtotime($current_date)))) {
// Wenn das Datum aus dem Feed dem gestrigen Datum entspricht
echo '<span style="color: red;">•</span>';
} else {
// Wenn das Datum aus dem Feed weder dem aktuellen noch dem gestrigen Datum entspricht
echo '<span style="color: gray;">•</span>';
}
// Output the item as a link
echo ' <a href="'.$link.'" title="'.$title.'" target="_blank">'.$title.'</a><br>';
}
?>