How could i create carbon object from given datetime structure?

You can use parse():

Carbon::parse($dateString);

Or you can use $dates property to create Carbon instance automatically for the column:

protected $dates = ['custom_date'];

Here is the official way from the Carbon docs:

Finally, if you find yourself inheriting a \DateTime instance from another library, fear not! You can create a Carbon instance via a friendly instance() function.

$dt = new \DateTime('first day of January 2008');   // <== instance from another API
$carbon = Carbon::instance($dt);
echo get_class($carbon);                               // 'Carbon\Carbon'
echo $carbon->toDateTimeString();                      // 2008-01-01 00:00:00

Also shown here


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