phplaravellaravel-5php-carbon

How could I create a Carbon object from a given datetime structure?


I use Laravel, and I need to create a Carbon object from the timestamp that I received.

Timestamp: 'yy-mm-dd HH:mm'

Example: '2016-12-20 10:26'

Is this possible?

Or is there another solution?


Solution

  • Use Carbon::parse('2016-12-20 10:26');. It will return a Carbon object.