output from 'in.attendance_time as in_time', 'out.attendance_time as out_time',
$absen = DB::table('attendance as in')
->where('in.in_out', 'in')
->where('in.company_id', \Session::get('selected_company'))
->whereDate('in.created', Carbon::today())
->leftJoin('attendance as out', function ($join) {
$join->on('in.employee_id', 'out.employee_id')
->where('out.in_out', 'out')
->where('out.company_id', \Session::get('selected_company'))
->whereDate('out.created', Carbon::today());
})
->join('employee', 'employee.id', 'in.employee_id')
->join('location_library', 'location_library.id', 'in.attendance_location_id')
->join('company as cp', 'cp.id', 'in.company_id')
->join('employee_in_app as e_app', 'e_app.employee_id', 'in.employee_id')
->join('employee_in_company', 'in.employee_id', 'employee_in_company.employee_id')
->select('employee.name', 'cp.alias', 'in.employee_id','location_library.location_name', 'in.attendance_time as in_time', 'out.attendance_time as out_time', 'e_app.note')
->orderBy('in.attendance_time', 'DESC')
->get();
I want to retrieve only hours, minutes and seconds without the date, month and year in the select, how to solve this problem? data showing date is 'in.attendance_time as in_time', 'out.attendance_time as out_time',
CodePudding user response:
Use This DB::raw
query for formating date
->select('employee.name', 'cp.alias', 'in.employee_id','location_library.location_name', DB::raw('DATE_FORMAT(in.attendance_time, "%H-%i-%s") as in_time'), DB::raw('DATE_FORMAT(out.attendance_time, "%H-%i-%s") as out_time'), 'e_app.note')