views:

21

answers:

2

Hi,

I am pulling a date string from an API. The returned string looks like this:

2010-09-02T09:46:48.78

I want to convert it to 02/09/2010 (dd/mm/yyyy) but

date_format($note['createdate'], "d/m/Y")

Results in error:

Warning: date_format() expects parameter 1 to be DateTime, string given in 

Can someone steer me in the right dirtection,

ta,

Jonesy

+5  A: 
echo date('d/m/Y',strtotime('2010-09-02T09:46:48.78'));

Why make it complicated ?!

MatTheCat
beautiful thanks!
iamjonesy
+3  A: 
date_format(new DateTime($note['createdate']), "d/m/Y")

or use strtotime as MatTheCat showed you.

Emil Vikström