<?php
$times = ['12:05', '14:05', '16:05', '18:05', '20:05'];
$now = new \DateTime();
$filteredTimes = array_filter($times, function ($time) use ($now) { $diff = (new \DateTime($time))->diff($now);
return $diff->invert && $diff->h * 60 + $diff->i >= 30;
});
echo sprintf("Now: %s\n", $now->format('H:i'));
$filteredTimes = array_filter($times, function ($time) use ($now) { $diff = (new \DateTime($time))->diff($now);
return (int)$diff->format('%R%i%') > 30;
});
PD9waHAKCiR0aW1lcyA9IFsnMTI6MDUnLCAnMTQ6MDUnLCAnMTY6MDUnLCAnMTg6MDUnLCAnMjA6MDUnXTsKJG5vdyA9IG5ldyBcRGF0ZVRpbWUoKTsKJGZpbHRlcmVkVGltZXMgPSBhcnJheV9maWx0ZXIoJHRpbWVzLCBmdW5jdGlvbiAoJHRpbWUpIHVzZSAoJG5vdykgewogICAgJGRpZmYgPSAobmV3IFxEYXRlVGltZSgkdGltZSkpLT5kaWZmKCRub3cpOwogICAgcmV0dXJuICRkaWZmLT5pbnZlcnQgJiYgJGRpZmYtPmggKiA2MCArICRkaWZmLT5pID49IDMwOwp9KTsKZWNobyBzcHJpbnRmKCJOb3c6ICVzXG4iLCAkbm93LT5mb3JtYXQoJ0g6aScpKTsKdmFyX2R1bXAoJGZpbHRlcmVkVGltZXMpOwoKJGZpbHRlcmVkVGltZXMgPSBhcnJheV9maWx0ZXIoJHRpbWVzLCBmdW5jdGlvbiAoJHRpbWUpIHVzZSAoJG5vdykgewogICAgJGRpZmYgPSAobmV3IFxEYXRlVGltZSgkdGltZSkpLT5kaWZmKCRub3cpOwogICAgdmFyX2R1bXAoKGludCkkZGlmZi0+Zm9ybWF0KCclUiVpJScpKTsKICAgIHJldHVybiAoaW50KSRkaWZmLT5mb3JtYXQoJyVSJWklJykgPiAzMDsKfSk7CnZhcl9kdW1wKCRmaWx0ZXJlZFRpbWVzKTs=