Hakan Gundogan
Hakan Gundogan

Reputation: 277

laravel date time problem on the database

I'm creating a table. There is a dateTime format in the migrations.

$table->dateTime('appointment_date');

When i create a row, the appointment date seems like that: 0000-00-00 00:00:00

My input like this:

enter image description here

What is the problem i could not solve. If you help me i will be glad. Thanks

Upvotes: 0

Views: 192

Answers (1)

Rouhollah Mazarei
Rouhollah Mazarei

Reputation: 4153

I think the problem is about formatting.

You can use Carbon to make sure the correct format is going to seat in the table. For example in your controller do something like this:

$whatever->appointment_date = Carbon\Carbon::parse($request->appointment_date);

P.S.

So, after the comment, we found that the main problem was the input format. The format should be something like this: 2021-09-05 02:46.

Upvotes: 2

Related Questions