Ok !
Example : 10:12 pm July 8th to 2002-07-08 22:12:00
<?
$months = array("january" => "01", "february" => "02", "march" => "03", "april" => "04", "may" => "05", "june" => "06", "july" => "07", "august" => "08", "september" => "09", "october" => "10", "november" => "11", "december" => "12");
$str = "10:12 pm July 8th";
$str = explode(" ", $str);
$hourmin = $str[0];
$ampm = strtolower($str[1]);
$month = $months[strtolower($str[2])];
$day = preg_replace("([^0-9])", "", $str[3]);
$hourmin = explode(":", $hourmin);
$hour = $hourmin[0];
$min = $hourmin[1];
$year = date("Y");
if($ampm == "pm") {
$hour += 12;
}
if($day < 10) {
$day = "0" . $day;
}
$newdate = "$year-$month-$day $hour:$min:00"
?>
I tested it and it worked perfectly. The only point which was different from what you wanted is the year... Since we are in 2003, it prints 2003 and not 2002..