laravel表格导入日期转换
use Illuminate\Support\Carbon;
use PhpOffice\PhpSpreadsheet\Shared\Date;
public function transformDateTime($value, string $format = 'Y-m-d H:i:s')
if (!is_numeric($value)) {
return $value;
}
{
try {
return Carbon::instance(Date::excelToDateTimeObject($value))->format($format);
} catch (\ErrorException $e) {
return Carbon::createFromFormat($format, $value);
}
}