Fabio Santos Fabio Santos - 1 year ago 226
PHP Question

laravel 5 format datetime

I have an array that return the following date time:

$item['created_at'] => "2015-10-28 19:18:44"

And I need this outuput:


Exist any function to convert this date?

Answer Source

Try this:

$dt = new \DateTime('2015-10-28 19:18:44', new \DateTimeZone('Europe/London'));
dd($dt->format('c')); // string '2015-10-28T19:18:44+00:00' (length=25)

Alternatively take a look at Carbon

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download