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

wontoneesaju's avatar

incorrect date value

hi

I am facing a issue called incorrect date value in controller file

Invalid datetime format: 1292 Incorrect date value: '10/10/2018' for column 'invduedate' at row 1 (SQL: insert into invoice(custid,compid,invduedate) values('5','1','10/10/2018'))

i want to know is there any function for this?

0 likes
3 replies
tykus's avatar

You can use Carbon to parse the date and pass it to the database in the required format:

// assuming the data comes from the Request object, change if appropriate
$invduedate = Carbon::createFromFormat('d/m/Y', $request-> invduedate);
wontoneesaju's avatar

$duedate=Carbon::createFromFormat('d/m/Y', $req->input('invduedate'));

its saying data missing

tykus's avatar

What does $req->input('invduedate') give you? I would expect that exception if there was an empty, null, or incomplete date (e.g. 10/2018) that did not match the given format

Please or to participate in this conversation.