Maybe its an integer. That is how the built ind date type in excel is stored. I use this to convert it
$date = $row['date']
if (is_numeric($date)) {
$date = ($date - 25569) * 86400;
}
$date = Carbon::parse($date)->toDateString()
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to import my csv but I'm getting error on date rows using SpartnerNL/Laravel-Excel
The separation symbol could not be found Unexpected data found. Trailing data
here's my code
return new Statement([
'reading_date' => \Carbon\Carbon::createFromFormat('m/d/Y', $row['billdate']),
'due_date' => \Carbon\Carbon::createFromFormat('m/d/Y', $row['duedate']),
]);
in my csv:
billdate: 10/15/2022
duedate: 10/30/2022
Schema:
Schema::create('statements', function (Blueprint $table) {
$table->bigIncrements('id');
$table->date('reading_date')->nullable();
$table->date('due_date')->nullable();
});
this worked
'reading_date' => $row['billdate'] ? \Carbon\Carbon::createFromFormat('m/d/Y', $row['billdate'])->format('m/d/Y') : null,
'due_date' => $row['duedate'] ? \Carbon\Carbon::createFromFormat('m/d/Y', $row['duedate'])->format('m/d/Y') : null,
Please or to participate in this conversation.