$string = this is my message in 12-10-12, Orlando
に変換したい$new = this is my message in 12th October 2012, Orlando
。
PHPコードを手伝ってください
これで始められるはずです:
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
詳細については、phpの日付修飾子、DateTime拡張子、preg_replace_callbackを参照してください。