ESP-RAY
ESP-RAY

Reputation: 23

How can i get if early or late?

Here's my code I want to get if early or late thank you po

 $current_time = strtoupper(date("g:i a "));
             $time = strtoupper(date("g:i a ",strtotime($current_time)));
            //print_r($time);
            
            $start_time = $request->start_time; 
            $s_time = str_replace('/', '-', $start_time);
            $fstart_time= strtoupper(date('g:i a',strtotime($s_time)));
           //print_r($fstart_time);
             
            if ($time > $fstart_time){
                 print_r('early');
             }else{
                 print_r('late');
             }

Upvotes: 0

Views: 110

Answers (2)

N69S
N69S

Reputation: 17206

Here is a simple solution for your format

if (time() >= strtotime($request->start_time)) {
    print_r('early');
} else {
    print_r('late');
}

Upvotes: 2

ESP-RAY
ESP-RAY

Reputation: 23

Update i fix my problemm But thank youu in advance

here's my code

     $start_time = $request->start_time; 
            $s_time = str_replace('/', '-', $start_time);
            $fstart_time= strtoupper(date('g:i a',strtotime($s_time)));
            print_r($fstart_time);

if (time() >= strtotime($fstart_time)) {
            echo "early";
 } else{

            echo "late";
}

Upvotes: -1

Related Questions