在php中关闭文本字符串中的日期格式[关闭]

$string = this is my message in 12-10-12, Orlando

i want to convert it to $new = this is my message in 12th October 2012, Orlando.

Please help me with php code

This should get you started:

function convert_date($hit)
{
    $date = DateTime::createFromFormat("y-m-d", $hit[0]);

    if (!$date) //invalid date supplied, return original string
        return $hit[0]; 

    return $date->format("jS F Y");
}

$string = "this is my message in 12-10-12, Orlando or maybe 13-11-21";
$string = preg_replace_callback("~(\d{2}-\d{2}-\d{2})~", "convert_date", $string);
echo $string; //this is my message in 12th October 2012, Orlando or maybe 21st November 2013

Look at the php date modifiers, the DateTime extension and preg_replace_callback for further information.