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);
        }
    }
posted @ 2024-02-01 17:36  成文的博客  阅读(40)  评论(0编辑  收藏  举报