You are here:  » PUBDATE in a different format


PUBDATE in a different format

Submitted by sahertian on Tue, 2008-05-06 08:36 in

Hi,

When parsing a rss feed, the pubdate is english. What options do I have to change the PUBDATE to a DUTCH format?

Thanks,
Ron

Submitted by support on Tue, 2008-05-06 10:13

Hello Ron,

It just so happens that I wrote some code just the other week for another customer who needed to convert other way round! Please check that my translations are correct

<?php
  
// create the conversion arrays in the global scope
  // days
  
$gb_d = array("mon","tue","wed","thu","fri","sat","sun");
  
$nl_d = array("ma""di""wo""do""vr""za""zo");
  
// months
  
$gb_m = array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
  
$nl_m = array("jan","feb","mrt","apr","mei","jun","jul","aug","sep","okt","nov","dec");
  function 
myRecordHandler($record)
  {
    
// bring in the translation arrays from the global scope in your record handler function
    
global $nl_d,$nl_m,$gb_d,$gb_m;
    
// make a copy of the original PUBDATE from the feed, and convert to lower case
    
$pubdate strtolower($record["PUBDATE"]);
    
// translate the days
    
$pubdate str_replace($gb_d,$nl_d,$pubdate);
    
// translate the months
    
$pubdate str_replace($gb_m,$nl_m,$pubdate);
    
// use ucwords() to convert back to correct case
    
$pubdate ucwords($pubdate);
    
// now you can use $pubdate, hopefully it will be in Dutch!
  
}
?>

All the best,
David.