Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Date time to carbon Instance

I'm using date time input field

<input type="datetime-local">

It returns a formatted date time yyyy-MM-ddThh:mm

Now i want to convert this format to Y-m-d H:i using php-carbon Package.

I have tried

 \Carbon\Carbon::createFromFormat(

    'yyyy-MM-ddTh:mm', $this->start_date

 )->format('Y-m-d H:i:s');

But it failed.

like image 568
Faid Avatar asked Dec 22 '22 20:12

Faid


1 Answers

you can use Carbon::parse for date parse.

\Carbon\Carbon::parse($this->start_date)->format('Y-m-d H:i');
like image 69
Dilip Hirapara Avatar answered Dec 25 '22 10:12

Dilip Hirapara