@param \DateTimeInterface        $date
@param string|FormatterInterface $formatString

@return string
347656
public static function format(\DateTimeInterface $date, $formatString)
    {
        $formater = new DateFormatter($formatString);
        return $formater->format($date);
    }
130174
public static String datetimeToCustomString(Date datetime, String formatWay) {
        return datetimeToCustomString(new SimpleDateFormat(formatWay), datetime);
    }
668362
public static function formatDate($date, $fromFormat='d-m-Y', $toFormat='Y-m-d')
    {   
        $dt = \DateTime::createFromFormat($fromFormat, $date);
        return !$dt ? null : $dt->format($toFormat);
    }
417520
static function Parse($format, $dateTimeString)
     {
         $dt = \DateTime::createFromFormat($format, $dateTimeString);
         if (!$dt)
             return null;
         
         return self::FromDateTime($dt);
     }
60205
public static function format($date = false, $format = 'Y-m-d H:i:s') {

        if($date) {

            $DateTime = new DateTime($date);
            return $DateTime->format($format);
        }

        return false;
    }
1341239
private function buildUrl(DateTimeInterface $requestedDate): string
    {
        return self::URL.'?'.http_build_query([self::DATE_QUERY_PARAMETER_NAME => $requestedDate->format(self::DATE_FORMAT)]);
    }
254183
protected static function createDate(string $date, string $format = 'Y-m-d'): \DateTime
    {
        return \DateTime::createFromFormat($format, $date);
    }
896519
public static function fromFormat(string $format, string $dateString, string $timeZoneId) : TimezonedDateTime
    {
        return new self(\DateTimeImmutable::createFromFormat('!' . $format, $dateString, new \DateTimeZone($timeZoneId)));
    }
665949
public function format(\DateTimeInterface $date)
    {
        if ($date->getOffset() == 0) {
            return $date->format('YmdHis\Z');
        }
        return str_replace(':', '\'', $date->format('YmdHisP')) . '\'';
    }
1033557
public static function buildFromDateTimeInterface(DateTimeInterface $date)
    {
        $parts = explode('|', $date->format('Z|I|T'));

        return new static((int)$parts[0], (bool)$parts[1], $parts[2]);
    }
734661
public static function formatDate($date)
    {
        $format = DateTime::ATOM;
        if ($date instanceof DateTime) {
            $d = $date->format($format);
        } elseif (is_numeric($date)) {
            $d = date($format, $date);
        } else {
            $d = (string) $date;
        }
        return $d;
    }
669236
public static function validateFormatType($formatType)
    {
        if (!in_array($formatType, [self::FORMAT_TYPE_DATE, self::FORMAT_TYPE_TIME, self::FORMAT_TYPE_DATETIME])) {
            throw new Exception\InvalidFormatTypeException('Provided formatType, "' . $formatType . '", is not one of allowed values.', 1281442590);
        }
    }
679115
public static function dateTime ($date, $timestamp = FALSE) {
		return ($timestamp) ? date('c',$date) : date('c', strtotime($date));
	}
872805
protected function formatDate(DateTimeInterface $date, PropDefinition $propDefinition): string
    {
        if (!$propDefinition->has('format')) {
            $propDefinition->set('format', $this->getDateFormat());
        }

        return $this->formatDatetime($date, $propDefinition);
    }
545502
public function formatDate($date)
    {
        // Get format
        $format = 'date_format';
        if ($this->get('time') === 'yes') {
            $format = 'datetime_format';
        }
        return DateTimeObj::format($date, DateTimeObj::getSetting($format));
    }
1111068
public static function hasFormat($date, $format)
    {
        try {
            // Try to create a DateTime object. Throws an InvalidArgumentException if the provided time string
            // doesn't match the format in any way.
            static::createFromFormat($format, $date);

            // createFromFormat() is known to handle edge cases silently.
            // E.g. "1975-5-1" (Y-n-j) will still be parsed correctly when "Y-m-d" is supplied as the format.
            // To ensure we're really testing against our desired format, perform an additional regex validation.
            $regex = strtr(
                preg_quote($format, '/'),
                static::$regexFormats
            );

            return (bool) preg_match('/^'.$regex.'$/', $date);
        } catch (InvalidArgumentException $e) {
        }

        return false;
    }
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');
    }