NEXT_MAJOR: Change to $date to \DateTimeInterface.

@param \IntlDateFormatter $formatter
@param \DateTime          $date

@return string
427391
public function process(\IntlDateFormatter $formatter, \DateTime $date)
    {
        // strange bug with PHP 5.3.3-7+squeeze14 with Suhosin-Patch
        // getTimestamp() method alters the object...
        return $this->fixCharset($formatter->format((int) $date->format('U')));
    }
458785
public function getFormattedDate(\DateTime $date, $formatAlias, $locale = '')
    {
        $locale = ('' != $locale) ? $locale : $this->defaultLocale;
        $format = $this->getFormat($locale, $formatAlias);

        return $this->formatDate($date, $format);
    }
511482
protected function inputDate( $date, $format = null )
    {
        if ( ! $date instanceof DateTime )
        {
            if ( $date instanceof BaseDateTime )
            {
                $date = DateTime::createFromFormat(
                    DateTime::ISO8601,
                    $date->format( DateTime::ISO8601 )
                );
            }

            if ( is_int( $date ) )
            {
                $date = new DateTime( '@' . $date );
            }
            else if ( empty( $format ) )
            {
                $date = new DateTime( $date );
            }
            else
            {
                $date = DateTime::createFromFormat( $format, $date );
            }
        }

        return $date;
    }
702622
private function formatDate(\DateTime $datetime = null, $format = 'Y_m_d')
    {
        if (null == $datetime) {
            $datetime = new \DateTime('now');
        }

        return $datetime->format($format);
    }
323899
public function getDate($date = null, $format = 'Y-m-d H:i:s')
    {
        if (strlen($date) < 0) {
            $date = date('d-m-Y H:i:s');
        }

        $timeStamp = new DateTime($date);
        return $timeStamp->format($format);
    }
267682
protected function getDateFormatter($dateFormat, $timeFormat, $calendar)
    {
        $datetype = isset($dateFormat) ? $this->getFormat($dateFormat) : null;
        $timetype = isset($timeFormat) ? $this->getFormat($timeFormat) : null;

        $calendarConst = $calendar === 'traditional' ? \IntlDateFormatter::TRADITIONAL : \IntlDateFormatter::GREGORIAN;
        
        $pattern = $this->getDateTimePattern(
            isset($datetype) ? $datetype : $dateFormat,
            isset($timetype) ? $timetype : $timeFormat,
            $calendarConst
        );
        
        return new \IntlDateFormatter(\Locale::getDefault(), $datetype, $timetype, null, $calendarConst, $pattern);
    }
748707
public static function getFormattedDate($date, $format)
    {
        if (StringUtils::isEmpty($date) || StringUtils::isEmpty($format)) {
            return null;
        }

        return date($format, 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);
    }
709889
protected function valueToDateTime($date)
    {
        if (!$date instanceof \DateTime) {
            $date = is_int($date) ? \DateTime::createFromFormat('U', $date) : new \DateTime((string)$date);
        }
        
        return $date;
    }
217777
public function toSqlDate(DateTimeInterface $date, Provider $provider = null) : string
    {
        $this->setParameterProvider($provider);

        return $date->format($provider->getDateFormat());
    }
253880
public static function date2timestamp($date, $format = null)
    {
        $config = Grav::instance()['config'];
        $dateformat = $format ?: $config->get('system.pages.dateformat.default');

        // try to use DateTime and default format
        if ($dateformat) {
            $datetime = \DateTime::createFromFormat($dateformat, $date);
        } else {
            $datetime = new \DateTime($date);
        }

        // fallback to strtotime() if DateTime approach failed
        if ($datetime !== false) {
            return $datetime->getTimestamp();
        }

        return strtotime($date);
    }
1174726
public static function formatOrNull($dateTime, $format = 'Y-m-d H:i:s', $null = null)
    {
        if ($dateTime instanceof \DateTime) {
            return $dateTime->format($format);
        } elseif (ValueHelper::isDateTime($dateTime)) {
            return static::stringToDateTime($dateTime)->format($format);
        } else {
            return $null;
        }
    }
652836
protected static function _strftime($format, $date) {
		$format = strftime($format, $date);
		$encoding = Configure::read('App.encoding');

		if (!empty($encoding) && $encoding === 'UTF-8') {
			$valid = mb_check_encoding($format, $encoding);
			if (!$valid) {
				$format = utf8_encode($format);
			}
		}
		return $format;
	}
46749
public static function ConvertDate($source, $sourceFormat, $targetFormat, $separator = "/", $hour = false)
	{
		$timestamp = DateUtil::TimeStampFromStr($source, $sourceFormat, $hour);
		return DateUtil::FormatDate($timestamp, $targetFormat, $separator, $hour);
	}
1075073
protected function formatDateTime(\DateTime $date = null, $format = null)
    {
        return $date && $format ?
            $date->format($format) :
            $date
        ;
    }
31223
protected function formatDatetime(DateTimeInterface $date, PropDefinition $definition): string
    {
        $timezone = $definition->get('timezone', $this->getDefaultTimezone());
        if ($timezone !== null) {
            $date = $this->convertTimeZone($date, $timezone);
        }

        return $date->format($definition->get('format', $this->getDatetimeFormat()));
    }
561091
public function dateTransform($date_value, $format_origin = 'd/m/Y H:i:s', $format_destiny = 'Y-m-d H:i:s')
    {
        $date = \DateTime::createFromFormat($format_origin, $date_value);
        return $date !== false ? $date->format($format_destiny) : '';
    }