Prepara data para validar.

@param mixed $date

@return null|string se for uma data valida retorna string no formato universal ou falso caso contrario.
163346
protected static function prepareDate($date)
    {
        if (null === $date) {
            return null;
        }
        if ($date instanceof DateTime) {
            return static::timeToString($date->getTimestamp());
        } elseif (is_numeric($date)) {
            return static::timeToString($date);
        } elseif (is_array($date)) {
            return @$date['date'];
        } elseif (self::hasTimestamp($date)) {
            return static::timeToString($date->getTimestamp());
        } elseif (is_string($date)) {
            return false !== strtotime($date) ? $date : null;
        }

        return null;
    }
1346450
public function textualDateFilter($date)
    {
        if ( ! $date instanceof \DateTime) {
            throw new \InvalidArgumentException('Textual Date Filter expects input to be a instance of DateTime');
        }

        $now  = new \DateTime('now');
        $diff = $now->diff($date);

        $diffUnit          = $this->getHighestDiffUnitAndValue($diff);
        $temporalModifier  = ($diff->invert)? 'ago':'next';
        $translationString = $temporalModifier. '.' .$diffUnit['unit'];

        // Override yesterday and tomorrow
        if ($diffUnit['unit'] == 'd' && $diffUnit['value'] == 1) {
            $translationString = ($diff->invert)? 'date.yesterday':'date.tomorrow';
        }

        // Override "just.now"
        if ($diffUnit['unit'] == 'now') {
            $translationString = 'date.just_now';
        }

        return $this->translator->transChoice($translationString, $diffUnit['value'], array('%value%' => $diffUnit['value']), 'date');
    }
946131
public static function shortDate($date)
    {
        if (self::isDate($date)) {
            $str = self::dateTimeToTimeStamp($date);
            $string = date("d.m.Y", $str);
            return $string;
        } else {
            return null;
        }
    }
900358
function validateDate($date = null)
    {
        if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) {
            return false;
        }

        if (!isset($date)) {
            $date = new DateTime($date, new DateTimeZone(@date_default_timezone_get()));
        }

        $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 < new DateTime($notBefore, new DateTimeZone(@date_default_timezone_get())):
            case $date > new DateTime($notAfter, new DateTimeZone(@date_default_timezone_get())):
                return false;
        }

        return true;
    }
231352
private function prepareDate(string $date)
    {
        if(preg_match("/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/i", $date)) $date = explode(" ", $date)[0];

        foreach (preg_split("/\W/i", $date) as $i => $dado) {
            $this->getDatePart($i, $dado);
        }

        $this->checkErro();
        $this->checkMonthEdge();
    }
183710
public static function parseDateMDYReadable(string $date): ?\DateTimeImmutable
    {
        $date = str_replace('  ', ' ', $date);

        if (preg_match('~[a-zA-z]+ \d+, \d{4}~', $date)) {
            return new \DateTimeImmutable($date, new \DateTimeZone('UTC'));
        }

        return null;
    }
174504
public function getTargetFromDate($date)
    {
        if (!preg_match('/^\d{4,14}$/', $date)) {
            throw new \InvalidArgumentException('Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].');
        }

        // what we need to append to the date according to the possible date string lengths
        $dateStrlenToAppend = [
            14 => '',
            12 => '00',
            10 => '0000',
            8 => '000000',
            6 => '01000000',
            4 => '0101000000',
        ];

        if (!isset($dateStrlenToAppend[strlen($date)])) {
            throw new \InvalidArgumentException('Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].');
        }

        $target = $date . $dateStrlenToAppend[strlen($date)];

        $dateTime = \DateTime::createFromFormat('YmdHis', $target);

        if ($dateTime === false) {
            throw new \InvalidArgumentException('Invalid date. Format is YYYY[MM[DD[HH[II[SS]]]]].');
        }

        return $dateTime->format('YmdHis');
    }
681718
public static function isDate($date): bool
    {
        if (!\preg_match('/^([\d]{4})-((?:0?[\d])|(?:1[0-2]))-((?:0?[\d])|(?:[1-2][\d])|(?:3[01]))( [\d]{2}:[\d]{2}:[\d]{2})?$/',
            $date, $matches)) {
            return false;
        }

        return \checkdate((int)$matches[2], (int)$matches[3], (int)$matches[1]);
    }
1025564
public static function formatDate($date, $format = 'Y-m-d')
    {
        if (!$date) {
            return null;
        }
        $date = new DateTime($date);
        return $date->format($format);
    }
670409
protected function _convertDate($date)
    {
        // regexps to validate input
        $datePatterns = [
            "/^([0-9]{2})\.([0-9]{4})/" => "EUR2", // MM.YYYY
            "/^([0-9]{2})\.([0-9]{2})/" => "EUR1", // DD.MM
            "/^([0-9]{2})\/([0-9]{4})/" => "USA2", // MM.YYYY
            "/^([0-9]{2})\/([0-9]{2})/" => "USA1" // DD.MM
        ];

        // date/time formatting rules
        $dateFormats = [
            "EUR1" => [2, 1],
            "EUR2" => [2, 1],
            "USA1" => [1, 2],
            "USA2" => [2, 1]
        ];

        // looking for date field
        $dateMatches = [];
        $stringModifier = getStr();
        foreach ($datePatterns as $pattern => $type) {
            if ($stringModifier->preg_match($pattern, $date, $dateMatches)) {
                $date = $dateMatches[$dateFormats[$type][0]] . "-" . $dateMatches[$dateFormats[$type][1]];
                break;
            }
        }

        return $date;
    }
380021
public function date($date)
    {
        if (! $date instanceof DateTime) {
            $date = new DateTime($date);
        }

        $this->executionYear = $date->format('Y');

        return $this->at("{$date->format('i')} {$date->format('H')} {$date->format('d')} {$date->format('m')} *");
    }
646610
protected function isValidDate($date)
    {
        $dt = DateTime::createFromFormat('Y-m-d', $date);

        return ($dt !== false && !array_sum($dt->getLastErrors()));
    }
1223044
static function longDateString($date) {
        str_replace('now', date('m.d.y'), $date);

        if (!self::parsable($date)) return null;

        $r = self::fromString($date);

        return $r->format('M d, Y');
    }
794638
public static function normalize(\DateTime $date = null)
    {
        if (!empty($date)) {
            return $date->format(static::DATE_FORMAT);
        }

        return null;
    }
419155
protected static function strBrToUs($date)
    {
        if (is_string($date)) {
            $expreg = '/^(0[1-9]|[1-2][0-9]|3[0-1])\/(0[1-9]|1[0-2])\/(\d{4})(T| ){0,1}(([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])){0,1}$/';
            if (preg_match($expreg, $date, $datebit)) {
                @list($tudo, $dia, $mes, $ano, $tz, $time, $hora, $min, $seg) = $datebit;

                return "$ano-$mes-$dia" . ($hora | $min | $seg ? "$hora:$min:$seg" : "");
            }
        }
        return null;
    }
457780
public function setDateTimeFrom($date = null)
    {
        $date = $this->resolveCarbon($date);

        return $this->modify($date->rawFormat('Y-m-d H:i:s.u'));
    }
1095704
public function date($date, $format = null)
	{
		$datetime = DateTimeUtil::getDateTime($date);
        if (empty($format)) {
			$format = $this->cfg['date_format'];
		}
		if ($format == 'rel') {
			$date = DateTimeUtil::getRelTime($datetime);
		} else {
			$date = $datetime->format($format);
		}
		return $date;
	}