views:

341

answers:

3

Hi,

I have the following date format: 2010-04-15 23:59:59

How would I go about converting this into: 15th Apr 2010

Thanks

+2  A: 

In addition to using date and strtotime, you can do

$dateTime = new DateTime('2010-04-15 23:59:59');
echo $dateTime->format('jS M Y'); // 15th Apr 2010

or

$dateTime = date_create('2010-04-15 23:59:59');
echo date_format($dateTime, 'jS M Y'); // 15th Apr 2010
Gordon
And thank you for your help Gordon, I see there are quite a few ways to play around with the solution.
Keith Donegan
+8  A: 
echo date("jS M Y",strtotime("2010-04-15 23:59:59"));
oezi
Thank you very much Oezi
Keith Donegan
+3  A: 
$date = date("dS M Y",strtotime("2010-04-15 23:59:59"));

print $date;
x4tje
"d" is day of month with leading zero, i think in this case "j"(day of month without leading zero) would be the better solution.
oezi
Thank you for your help x4tje
Keith Donegan