fork download
  1. <?php
  2.  
  3. $current_time = '4:00';
  4. $time_slot = ['1:00','3:00','15:00','19:00'];
  5.  
  6. $current_date = new \DateTime($current_time);
  7.  
  8. foreach($time_slot as $index => $value) {
  9. if ($current_date > new \DateTime($value)) unset($time_slot[$index]);
  10. }
  11. var_dump($time_slot);
Success #stdin #stdout 0.03s 23848KB
stdin
Standard input is empty
stdout
array(2) {
  [2]=>
  string(5) "15:00"
  [3]=>
  string(5) "19:00"
}