1 回答

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超5個(gè)贊
我在 Laravel 項(xiàng)目中使用 Carbon。我嘗試更改以下日期格式。我找不到任何錯(cuò)誤,但它顯示找不到分隔符號(hào)。這就是我所做的
$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;
});
- 1 回答
- 0 關(guān)注
- 161 瀏覽
添加回答
舉報(bào)