I want to convert a date by the following statement
$date=date(\'d M Y, H:m\',strtotime($date));
It printed out 09 Sep 2012, 11:09
Looks like the only way to go is to sort the elements in proper order by regular expressions and then replace the month name by corresponding number. Such a string strtotime will manage. Note: I'm talking about PHP 5.2x
EDIT: I found the reason, why strtotime "wasn't working" was that I made a typo in the date formating string, there should be 'd M Y, H:i'
Valid formats for strtotime
are detailed here.
From this site (http://www.tuxradar.com/practicalphp/4/5/2)
Be wary of dates such as this one: August 25, 2003, 10:26am. Although this may look perfectly well-formed, strtotime() is not able to handle it because it has commas in there - yes, they make it much more readable for us, but strtotime() gets confused handling them. If you have dates with commas in, be sure to strip them out using str_replace().
How to deal with strtotime() -> http://www.w3schools.com/php/func_date_strtotime.asp