I have a case where I import a csv, and what I do is:
$tdate = new \DateTime($array[$i][2]);
// comes in as 2/15/2019 just example
$ndate = $tdate->format('Y-m-d');
And why do you need the time on a date field.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey all,
I am having trouble updating datetime fields in the database for Microsoft SQL Server (migrating existing app to Laravel). I get various errors depending on what I set my date formatting to, but I can't seem to stop the errors:
Y-m-d H:i:s.v and Y-m-d H:i:s.u gives me the error:
Conversion failed when converting date and/or time from character string.
**Y-m-d H:i:s.v0** gives me the error:
Data missing
And Y-m-d H:i:s gives me the error:
Trailing Data
I'm not sure what else to use, but this is the structure of dates saved in the db is *2019-07-12 14:34:28.000*. If you have any recommendations I would love to hear them, thanks!
EDIT: I should clarify that I am using Carbon to generate the dates that give me the error like so:
Carbon::now()->addDays(1)->format($this->dateFormat);
Please or to participate in this conversation.