If you want to enlarge strtotime php function to be tolerant about funny date (especially in mail header), here is a little function :
function strtotime_tolerant($time)
{
$datetime_header = strtotime($time) ;
if ($datetime_header === false)
{
if (preg_match(‘/(Wen, .*)/’, $time))
{
$time = (preg_replace(‘/(Wen,) (.*)/’, ‘Wed, ${2}’, $time));
}
if (preg_match(‘/(Sut, .*)/’, $time))
{
$time = (preg_replace(‘/(Sut,) (.*)/’, ‘Sat, ${2}’, $time));
}
if (preg_match(‘/(Tues, .*)/’, $time))
{
$time = (preg_replace(‘/(Tues,) (.*)/’, ‘Tue, ${2}’, $time));
}
if (preg_match(‘/(.* \d\d:\d\d:\d\d) (.\d{4})/’, $time, $matches))
{
$time = $matches[1].’ ‘.$matches[2];
}if (preg_match(‘/(.* \d\d:\d\d:\d\d) (\d{4})/’, $time))
{
$preg_time = (preg_replace(‘/(.* \d\d:\d\d:\d\d) (\d{4})/’, ‘${1} +${2}’, $time));
}
if (preg_match(‘/(.* \d\d:\d\d:\d\d) (UT)$/’, $time))
{
$preg_time = (preg_replace(‘/(.* \d\d:\d\d:\d\d) (UT)$/’, ‘${1} ${2}C’, $time));
}
if (preg_match(‘/(.* \d\d:\d\d:\d\d) (CEDT)$/’, $time))
{
$preg_time = (preg_replace(‘/(.* \d\d:\d\d:\d\d) (CEDT)$/’, ‘${1} +0200’, $time));
}
if (preg_match(‘/(.* \d\d:\d\d:\d\d) (.0060)/’, $time))
{
$preg_time = (preg_replace(‘/(.* \d\d:\d\d:\d\d) (.0060)/’, ‘${1} +0100’, $time));
}if(isset($preg_time))
{
$time = $preg_time;
}
}return strtotime($time);
}