- ';
foreach ($rss->channel->item as $item){
setlocale(LC_TIME, 'french.UTF-8', 'fr_FR.UTF-8'); // ok caractères accentués
date_default_timezone_set('Europe/Paris'); // OK pour l'heure de publication
$datetime = date_create($item->pubDate);
$date = date_format($datetime, 'd F Y'); // original
$hDate = date_format($datetime, 'H:i:s');
//$date2 = date('l F d, Y', strtotime($datetime)); //donne Thursday January 01, 1970
$seconds = time() - strtotime($item->pubDate);
$year = floor($seconds /31556926);
$months = floor($seconds /2629743);
$week=floor($seconds /604800);
$day = floor($seconds /86400);
$hours = floor($seconds / 3600);
$mins = floor(($seconds - ($hours*3600)) / 60);
$secs = floor($seconds % 60);
if($seconds < 60) $time = "Publié à l'instant";
else if($seconds < 3600 ) $time = ($mins==1)? " Publié à l'instant": " Publié il y a ". $mins." minutes";
else if($seconds < 86400) $time = ($hours==1)? " Publié il y a ". $hours. " heure": " Publié il y a ".$hours. " heures";
else if($seconds < 604800) $time = ($day==1)? " Publié il y a ". $day. " jour": " Publié il y a ".$day. " jours";
else if($seconds < 2629743) $time = ($week==1)? " Publié il y a ". $week. " semaine": " Publié il y a ".$week. " semaines";
else if($seconds < 31556926) $time = ($months==1)? " Publié il y a ". $months." mois": " Publié il y a ".$months." mois";
else $time = ($year==1)? " Publié il y a ". $year. " an": " Publié il y a ".$year. " ans";
// return $time;
echo "
- link')\">".$item->title. "" .
''. ''. $time . ''. // 'le ' . $date2 = strftime('%d %B %Y', strtotime($date)) . ''. 'le ' . $date2 = strftime('%d %B %Y', strtotime($item->pubDate)) . ''. // 'à '. $date3 = utf8_encode(strftime('%H : %M : %S', strtotime($hDate))) . ' 'à '. $hDate = strftime("%H:%M:%S", strtotime($item->pubDate)). ''.''. ''. '
' .$item->description.'
'.' ';
}
echo '
';
echo '
';
?>