src/Common/CodeIgniter/Libraries/FormValidation.php
public function valid_time($sTime, $sFormat)
    {
        //  If blank, then assume the date is not required
        if (empty($sTime)) {
            return true;
        }

        if (empty($sFormat)) {
            $sFormat = 'H:i:s';
        }

        if (!array_key_exists('valid_time', $this->_error_messages)) {
            $this->set_message('valid_time', lang('fv_valid_time_field'));
        }

        try {

            $oDate = \DateTime::createFromFormat($sFormat, $sTime);

            if (empty($oDate)) {
                return false;
            }

            return $oDate->format($sFormat) == $sTime;

        } catch (\Exception $e) {

            return false;
        }
    }
public function valid_time($sTime, $sFormat)
    {
        //  If blank, then assume the date is not required
        if (empty($sTime)) {
            return true;
        }

        if (empty($sFormat)) {
            $sFormat = 'H:i:s';
        }

        if (!array_key_exists('valid_time', $this->_error_messages)) {
            $this->set_message('valid_time', lang('fv_valid_time_field'));
        }

        try {

            $oDate = \DateTime::createFromFormat($sFormat, $sTime);

            if (empty($oDate)) {
                return false;
            }

            return $oDate->format($sFormat) == $sTime;

        } catch (\Exception $e) {

            return false;
        }
    }
public function valid_time ( $ sTime , $ sFormat ) { //  If blank, then assume the date is not required if ( empty ( $ sTime ) ) { return true ; } if ( empty ( $ sFormat ) ) { $ sFormat = 'H:i:s' ; } if ( ! array_key_exists ( 'valid_time' , $ this -> _error_messages ) ) { $ this -> set_message ( 'valid_time' , lang ( 'fv_valid_time_field' ) ) ; } try { $ oDate = \ DateTime :: createFromFormat ( $ sFormat , $ sTime ) ; if ( empty ( $ oDate ) ) { return false ; } return $ oDate -> format ( $ sFormat ) == $ sTime ; } catch ( \ Exception $ e ) { return false ; } }
Checks if a time string is valid

@param string $sTime   The time string to check
@param string $sFormat The format the string is in

@return boolean
Checks if a time string is valid