1 回答
TA贡献1802条经验 获得超5个赞
我在 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;
});
- 1 回答
- 0 关注
- 97 浏览
添加回答
举报