找不到分隔符号 发现意外数据。追踪数据 Carbon Laravel

我在 Laravel 项目中使用 Carbon。我尝试更改以下日期格式。我找不到任何错误,但它显示找不到分隔符号。这就是我所做的


$employees = $request->get('employeeIds');

    $inTimes = $request->get('inTime');

    $outTimes = $request->get('outTime');


    $attendance_date = Carbon::createFromFormat('d/m/Y', $request->get('attendance_date'))->format('Y-m-d');


    //fetch employee working hours

    $workTimes = Employee::where('status', AppHelper::ACTIVE)->get()->reduce(function ($workTimes, $employee) use ($request) {

        $workTimes[$employee->id] = [

            'in_time' => null,

            'out_time' => null

        ];

        if ($employee->duty_start) {

            $workTimes[$employee->id]['in_time'] = Carbon::createFromFormat('d/m/Y H:i:s', $request->get('attendance_date') . ' ' . $employee->getOriginal('duty_start'));

        }


        if ($employee->duty_end) {

            $workTimes[$employee->id]['out_time'] = Carbon::createFromFormat('d/m/Y H:i:s', $request->get('attendance_date') . ' ' . $employee->getOriginal('duty_end'));

        }


        return $workTimes;

    });


波斯汪
浏览 98回答 1
1回答

慕后森

我在 Laravel 项目中使用 Carbon。我尝试更改以下日期格式。我找不到任何错误,但它显示找不到分隔符号。这就是我所做的$employees = $request->get('employeeIds');    $inTimes = $request->get('inTime');    $outTimes = $request->get('outTime');    $attendance_date = Carbon::createFromFormat('d/m/Y', $request->get('attendance_date'))->format('Y-m-d');    //fetch employee working hours    $workTimes = Employee::where('status', AppHelper::ACTIVE)->get()->reduce(function ($workTimes, $employee) use ($request) {        $workTimes[$employee->id] = [            'in_time' => null,            'out_time' => null        ];        if ($employee->duty_start) {            $workTimes[$employee->id]['in_time'] = Carbon::createFromFormat('d/m/Y H:i:s', $request->get('attendance_date') . ' ' . $employee->getOriginal('duty_start'));        }        if ($employee->duty_end) {            $workTimes[$employee->id]['out_time'] = Carbon::createFromFormat('d/m/Y H:i:s', $request->get('attendance_date') . ' ' . $employee->getOriginal('duty_end'));        }        return $workTimes;    });
打开App,查看更多内容
随时随地看视频慕课网APP