Tools\Model\Table\Table::validateTime PHP Method

validateTime() public method

Validation of Time fields
public validateTime ( mixed $value, array $options = [], array $context = [] ) : boolean
$value mixed
$options array - timeFormat (defaults to 'hms') - allowEmpty - after/before (fieldName to validate against) - min/max (defaults to >= 1 - at least 1 minute apart)
$context array
return boolean Success
    public function validateTime($value, $options = [], array $context = [])
    {
        if (!$value) {
            return false;
        }
        $dateTime = explode(' ', $value, 2);
        $value = array_pop($dateTime);
        if (Validation::time($value)) {
            // after/before?
            if (!empty($options['after']) && isset($context['data'][$options['after']])) {
                if ($context['data'][$options['after']] >= $value) {
                    return false;
                }
            }
            if (!empty($options['before']) && isset($context['data'][$options['before']])) {
                if ($context['data'][$options['before']] <= $value) {
                    return false;
                }
            }
            return true;
        }
        return false;
    }