Max
Max

Reputation: 19

How to set 2 shift schedules with PHP

I would like to know if you could help me with this question.

I need to set 2 time slots, for example shift schedules: 6:00 AM-6: 00PM shift 1 6:00 PM-6: 00AM shift 2

My goal is to show a report of the jobs and records that are carried out during the day, in the production department, according to the shift in which they are.

I just need to know what shift they are in when they query the Dashboard.

Example:

public function ReportProduccionX () {
     $date = date ('H: i: s', $time);
     if (6:00 am> $ date <6:00 pm) {
       $turn1 on;
     }
    else {
       $turn2 on;
     }
}

In the future, setting the schedules would be programmable from a dashboard, assigning start and end variables for a specific shift.

Upvotes: 0

Views: 192

Answers (1)

Chilarai
Chilarai

Reputation: 1888

There you go.

public function ReportProduccionX () {
    // This gives 24 hr time
    $date = date ('H', $time);

    // If date is greater than 6am and less than equal to 6pm
    if ($date >= 6 && $date <= 17) {
        // $turn1 on;
    }
    else {
        // $turn2 on;
    }   
}

EDIT

As rightly pointed out by @kmoser, I have updated the condition

Upvotes: 2

Related Questions