I have an Excel file, where I have a date column. The date looks like "17.07.2020".
I'm using Laravel and Maatwebsite Excel import. When I'm saving the imported data to MySQL, the date in MySQL is always "1970-01-01".
Here is the code, which I have now:
return new Product([
.......
'discountBeginning' => date('Y-m-d', strtotime($row['discount_beginning'])
]);
I would like to format the date from Excel to "2020-07-17".
Try this
$date = new DateTime($row['discount_beginning']);
echo $date->format('d.m.Y');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With