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

jukia's avatar
Level 1

how to change date format

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '04-25-2023' for column ibs.acquires.acquire_date at row 1

my code $date = new \DateTime($request->ac); // use your CSV field here. $acq->acquire_date= $date->format('m-d-Y'); $tdate = new \DateTime($request->da; // use your CSV field here. $acq->expire_date= $tdate->format('m-d-Y');

i want my date format like(month,day,year) but it gaving me error mysql dateformat (year ,month,day) how to customized this and mysql datatype is date

0 likes
6 replies
jukia's avatar
Level 1

not solved my problem SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: 'April 19, 2023' for column ibs.acquires.acquire_date at row 1

Snapey's avatar

mysql needs to receive dates in Y-m-d format . don't try to change it.

Just display it differently when you need to present it to a user

jukia's avatar
Level 1

@m7vm7v also gave some code because i am not good reading documentation

Snapey's avatar

@jukia You didn't give any code because you did not format it in your question

Please or to participate in this conversation.