- preg_match: documentation ( source)
- strtotime: documentation ( source)
<?php
function fix_strtotime($date)
{
if(preg_match('/([012]?[0-9]?:[0-5]{1}\d\s*[aA|pP]?[mM]?)(\s+)(.+)/', $date, $matches))
{
return strtotime($matches[3] . $matches[2] . $matches[1]);
}
return strtotime($date);
}
echo fix_strtotime('04:00 yesterday'); // 2010-09-17 14:00:00