开发者

PHP: Date format conversting string 2010-09-02T09:46:48.78 to dd/mm/yyyy

I am pulling a date string from an API. The 开发者_JS百科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


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

Why make it complicated ?!


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

or use strtotime as MatTheCat showed you.


There is a couple technics for this. But most useful is this.

   $dateRegistered = $row['registracion_date'];
   $formatDate = DATE_FORMAT(new DateTime($dateRegistered), 'd.m.Y г.');

Hope this helped a lot of guys out there. Cheers. @Vaseto.tk :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜