PHP从2011年11月25日到11月25日从xml Feed转换日期格式? [关闭]

Im importing content from an XML feed. The date format for the date field is 25 November 2011, which I need to convert into 25 Nov. Whats the best way to do this?

I could use str_replace to replace each month with its abbreviation, but im wondering if there is a cleaner solution.

The most elegant solution would be to use DateTime.

$date = new DateTime("25 November 2011");
echo $date->format("j M");

The quick/dirty version:

echo date('j M', strtotime('25 November 2011'));

if the input dates are potentially ambiguous (e.g. '1/2/3'), then use date_create_from_format() (or its OOP equivalent) instead.

 $newdate = date("d M", strtotime("25 November 2011"));

 echo $newdate;