Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nshahadat's avatar

Laravel date time not working

Hello

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. Any solutions?

0 likes
2 replies
tisuchi's avatar
tisuchi
Best Answer
Level 70

@nshahadat

you can use Carbon::parse() for date parse those are not the carbon instance.

\Carbon\Carbon::parse($this->start_date)->format('Y-m-d H:i');
1 like

Please or to participate in this conversation.