raihanafroz / zkteco

ZKTeco Laravel Library
151 stars 57 forks source link

How to get latest attendance record by dates #7

Open Zeeshan19-Dev opened 3 years ago

jmrashed commented 4 months ago
static public function getTodaysRecords(ZKTeco $self)
    {
        // Get all attendance records from the device
        $attendanceData = self::get($self);

        // Get today's date
        $currentDate = date('Y-m-d');

        // Filter attendance data for today
        $todaysAttendance = array_filter($attendanceData, function($record) use ($currentDate) {
            // Assuming the date format in the attendance data is 'Y-m-d H:i:s'
            return substr($record['timestamp'], 0, 10) === $currentDate;
        });

        return $todaysAttendance;
    }