Validates a datetime (format YYYY-MM-DD HH:MM:SS)

@param string $dateTime
@return boolean
496442
private function isDatetime($dateTime)
    {
        if (preg_match('/^(\d{4})-(\d\d?)-(\d\d?) (\d\d?):(\d\d?):(\d\d?)$/', $dateTime, $matches)) {
            return checkdate($matches[2], $matches[3], $matches[1]) && $matches[4] / 24 < 1 && $matches[5] / 60 < 1 && $matches[6] / 60 < 1;
        }
        return false;
    }
865299
public static function validate($string)
    {
        try {
            if (is_numeric($string) && (int)$string == $string) {
                $date = new DateTime('@' . $string);
            } else {
                $date = self::parse($string);
            }
        } catch (Exception $ex) {
            return false;
        }

        // String is empty or not a valid date
        if (empty($string) || $date === false) {
            return false;

            // String is a valid date
        } else {
            return true;
        }
    }
267344
def _validate_datetime(cls, value):
        
        datetime_check = validators.Int()
        datetime_check.to_python(value)
        if len(value) != 8:
            raise MlbAmBadParameter("Length Error:{value}({length})".format(value=value, length=len(value)))
1321171
public function setDateTime($dateTime)
	{
		$this->registry()->register(self::REGISTRY_DATETIME, $dateTime, true);
		return $this;
	}
1098811
public function validate()
    {
        $value = $this->getValue();

        if ($value instanceof \DateTime) return true;
        if (strtotime($value) === false) return false;
        $date = date_parse($value);

        return checkdate($date['month'], $date['day'], $date['year']);
    }
1133940
static public function validate($date)
    {
      // Check if date is a string
      if(is_string($date) && strlen(trim($date)) > 0)
        return false;
        
      // Check if date matches pattern
      if(!preg_match('/^' . self::PATTERN . '$/', $date, $matches))
        return false;
          
      // Extract values from date
      list($original, $year, $month, $day) = $matches;
          
      // Check if all values are valid
      if(!self::validateDate($year, $month, $day))
        return false;
            
      return true;
    }
856002
public static function datetime($value): bool
    {
        if ($value instanceof \DateTime) {
            return true;
        } elseif (strtotime($value) !== false) {
            return true;
        }

        return false;
    }
234086
public static function isValidDateTime($dateTime)
    {
        $t = explode(' ', $dateTime);
        if ($this->isValidDate($t[0]) && $this->isValidDate($t[1])) {
            return true;
        } else {
            return false;
        }
    }
1313308
public static function get_DateTime( &$dateTime )
    {
        if( $dateTime instanceof DateTime ) {
            return $dateTime;
        }
        return !is_null($dateTime)
            ? new DateTime( $dateTime )
            : null
            ;
    }
527291
public function isValid($value) : bool
    {
        if ($value === null && $this->nullable) {
            return true;
        }

        return $value instanceof \DateTimeImmutable;
    }
850270
public function validate($value) {
        $dateTime = \DateTime::createFromFormat($this->format, $value);
        if(!$dateTime instanceof \DateTime || $dateTime->format($this->format)!=$value) {
            return new ValidationResult(false, 'Invalid date');
        }

        return new ValidationResult(true);
    }
714447
function validateDate($date = NULL)
    {
        if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) {
            return false;
        }

        if (!isset($date)) {
            $date = time();
        }

        $notBefore = $this->currentCert['tbsCertificate']['validity']['notBefore'];
        $notBefore = isset($notBefore['generalTime']) ? $notBefore['generalTime'] : $notBefore['utcTime'];

        $notAfter = $this->currentCert['tbsCertificate']['validity']['notAfter'];
        $notAfter = isset($notAfter['generalTime']) ? $notAfter['generalTime'] : $notAfter['utcTime'];

        switch (true) {
            case $date < @strtotime($notBefore):
            case $date > @strtotime($notAfter):
                return false;
        }

        return true;
    }
199243
public static function verifyDateTime(string $datetime, string $format): bool
    {
        $formatted = DateTime::createFromFormat($format, $datetime);

        $errors = DateTime::getLastErrors();

        if (!empty($errors['warning_count'])) {
            return false;
        }

        return $formatted !== false;
    }
188018
public static function getDateSQLToForm($datetime)
    { 
        //YYYY-mm-dd
        $t = $this->splitDate($datetime, false);

        return $t['date'] . '/' . $t['month'] . '/' . $t['year'];
    }
439239
public static function validate($format, $timeString)
	{
		$time = DateTime::createFromFormat($format, $timeString);

		return ($time !== FALSE) && ($timeString === $time->format($format));
	}
708980
public function differenceDateTime($dateTime = null) {
        if (!empty($dateTime)) {
            $this->setDateTime($dateTime, true);
        }
        $this->dateTimeInterval = $interval = $this->dateTime->diff($this->dateTimeDiff);
        return $interval;
    }
162904
public static function isValid($date)
	{
		if(self::validateXSDDateTimeFormat($date) && self::validateXSDDateTimeValue($date))
		{
			return true;
		}
		else
		{
			return false;
		}
	}