Google Sitemap Generator For Textpattern

05.07.26, 11:41 AM

I installed Sencer’s Google Sitemap Plugin for Textpattern a while ago but I always had this “Invalid Date” status. That left me no choice but editing the date in all the tags of the xml file so Google Sitemap can read it properly.

Yesterday I came across to an article at YippeeSoft that described the same problem with another content management system, and the author’s solution for the problem.

I gave it a try by modifying the last php functions in the plugin and it works perfectly now :) This is the modified asy_iso8601() function. +0800 is my timezone. Same as above, MYT is my timezone, hence i replace MYT with T to make it in ISO-8601 standard time format.


function asy_iso8601_date($time) {
  $tzd = date("O", $time);
  $date = date("Y-m-dTH:i:s", $time);
  $date.= substr($tzd, 0, 3).":".substr($tzd, 3, 2);
  $date = str_replace("+08:00","+00:00",$date);
  # make it an iso-8601 standard time
  $date = str_replace("MYT","T",$date);
  return $date;
}

Update (Feb 23, 2006):
A better way to deal with it is to use the updated code below, it works with any server located at any place:


function asy_iso8601_date($time) {
  $date = gmdate("Y-m-dTH:i:s", $time);
  $date = str_replace("GMT","T",$date);
  $date = $date."+00:00";
  return $date;
}

Posted in Softwares