This is deprecated, and has known bugs. See here for a replacement.
Having searched around for any function to parse RFC3339 dates (used in Atom) in PHP, and failing to find any decent one, I wrote my own. In short, all it does is rearrange the date to a format strtotime() understands.
<?phpfunction parse_date($date)
{
if (preg_match('/([0-9]{2,4})-([0-9][0-9])-([0-9][0-9])T([0-9][0-9]):([0-9][0-9]):([0-9][0-9])(\.[0-9][0-9])?Z/i', $date, $matches))
{
if (isset($matches[7]) && substr($matches[7], 1) >= 50)
$matches[6]++;
return strtotime("$matches[1]-$matches[2]-$matches[3] $matches[4]:$matches[5]:$matches[6] -0000");
}
else if (preg_match('/([0-9]{2,4})-([0-9][0-9])-([0-9][0-9])T([0-9][0-9]):([0-9][0-9]):([0-9][0-9])(\.[0-9][0-9])?(\+|-)([0-9][0-9]):([0-9][0-9])/i', $date, $matches))
{
if (isset($matches[7]) && substr($matches[7], 1) >= 50)
$matches[6]++;
return strtotime("$matches[1]-$matches[2]-$matches[3] $matches[4]:$matches[5]:$matches[6] $matches[8]$matches[9]$matches[10]");
}
else
{
return strtotime($date);
}
}?>
I actually wrote this for SimplePie, and like the rest of SimplePie, is released under the Creative Commons Attribution License 2.5 it is released under the zlib/libpng license.