Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#10 rss_utils.inc

open-fixed
nobody
None
5
2004-11-22
2004-10-14
Giorgio Beggiora
No

Hi,

i tried to use the "parse_w3cdtf" function, but it
didn't work!

So i created a new function, maybe can be useful ti you:

function rssDate2phpDate($q){
$data = array();
$t = explode(" ",$q);
$data[d]=$t[1];
switch($t[2]){
case"Jan": $data[m]="01"; break;
case"Feb": $data[m]="02"; break;
case"Mar": $data[m]="03"; break;
case"Apr": $data[m]="04"; break;
case"May": $data[m]="05"; break;
case"Jun": $data[m]="06"; break;
case"Jul": $data[m]="07"; break;
case"Aug": $data[m]="08"; break;
case"Sep": $data[m]="09"; break;
case"Oct": $data[m]="10"; break;
case"Nov": $data[m]="11"; break;
case"Dec": $data[m]="12"; break;
}
$data[Y]=$t[3];
$t=explode(":",$t[4]);
$data[h]=$t[0];
$data[i]=$t[1];
$data[s]=$t[2];

return
mktime($data[h],$data[i],$data[s],$data[m],$data[d],$data[Y]);
}

Discussion

  • Logged In: YES
    user_id=22657

    looking at your function it looks to me like you were trying
    to parse an RFC-822 date (the format used by RSS 2.0) using
    the parse_w3cdtf method (the format used by RSS 1.0 and Atom)

     
  • Logged In: YES
    user_id=563286

    Sorry but i didn't understeand it from documentation :(
    So there's no way to parse an RSS2 date with the default
    installation of MagpieRSS?

     
  • Logged In: YES
    user_id=22657

    You can parse RSS 2.0 style dates with the built in PHP
    function strtotime().

    Also if you grab Magpie 0.7 then pubDate will automatically
    be parsed into $item['date_timestamp'] suitably for passing
    to PHP's date() function.

     
    • status: open --> open-fixed