Shortcut method for converting a date to UTC and returning the formatted string.

@param DateTimeInterface $date
@param PropDefinition    $propDefinition

@return string

@see FormatsFields::formatDateTime()
334851
protected function formatDatetimeUtc(DateTimeInterface $date, PropDefinition $propDefinition): string
    {
        return $this->formatDatetime($date, $propDefinition->set('timezone', 'UTC'));
    }
1031903
@Override
  public String formatDateTime(Locale locale, Date date) {
    return DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT, locale).format(date);
  }
722348
public function intlDateFormat($date)
    {
        if (($formatter = $this->getFormatter()) instanceof \IntlDateFormatter) {
            return $formatter->format($date);
        } elseif ($date instanceof \DateTime) {
            return $date->format('d-m-Y');
        }

        return date('d-m-Y', $date);
    }
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);
    }
2621
public function withExpiry(\DateTimeInterface $date): self
    {
        $new = clone $this;

        if ($date instanceof \DateTimeImmutable) {
            $new->expiry = $date;
        } elseif ($date instanceof \DateTime) {
            $new->expiry = \DateTimeImmutable::createFromMutable($date);
        } else {
            $new->expiry = new \DateTimeImmutable("@" . $date->getTimestamp());
        }

        return $new;
    }
687242
public static function refreshTokensExpireIn(DateTimeInterface $date = null)
    {
        if (is_null($date)) {
            return static::$refreshTokensExpireAt
                            ? Carbon::now()->diff(static::$refreshTokensExpireAt)
                            : new DateInterval('P1Y');
        }

        static::$refreshTokensExpireAt = $date;

        return new static;
    }
221944
private function dateTimeToTimePoint(DateTime $date)
    {
        // missing or offset only timezone? correct to UTC
        if (!$date->getTimezone() instanceof DateTimeZone || preg_match('#^[+-]{1}[0-9]{2}:?[0-9]{2}$#', $date->getTimezone()->getName())) {
            $date->setTimezone(new DateTimeZone('UTC'));
        }

        try {
            // DateTime::createFromFormat() will create an invalid DateTimeZone object when the timezone is an offset
            // (-05:00, for example) instead of a named timezone. By recreating the DateTimeZone object, we can expose
            // this problem and ensure that a valid DateTimeZone object is always set.
            $timezone = new DateTimeZone($date->getTimezone()->getName());
        } catch (Exception $e) {
            // @codeCoverageIgnoreStart
            $date->setTimezone(new DateTimeZone('UTC'));
            // @codeCoverageIgnoreEnd
        }

        return new TimePoint(
            (int) $date->format('Y'),
            (int) $date->format('m'),
            (int) $date->format('d'),
            (int) $date->format('H'),
            (int) $date->format('i'),
            (int) $date->format('s'),
            $date->getTimezone()->getName(),
            (int) $date->format('u')
        );
    }
860403
public function toIso8601Date(DateTimeInterface $dateTime, ?DateTimeZone $displayedTimeZone = null): string
    {
        if ($displayedTimeZone !== null && ($dateTime instanceof DateTime || $dateTime instanceof DateTimeImmutable)) {
            $dateTime = $dateTime->setTimezone($displayedTimeZone);
        }

        return $dateTime->format("Y-m-d");
    }
927220
protected function convertDate($date) : string
    {
        if (is_a($date, 'DateTime')) {
            return (string) $date->format(DateTime::ISO8601);
        }

        return $date;
    }
1255084
public static function formatDateLong(DateTime $date, $locale = null): string
    {
        $locale = $locale ?? 'fr';
        $localDates = [
            'fr'    => '%A %d %B %Y',
        ];
        return self::toLower(strftime($localDates[$locale], $date->getTimestamp()));
    }
484014
public function getDate(\DateTimeInterface $dateTime)
    {
        $date = new Date($dateTime);
        $this->loadDay($date);

        return $date;
    }
709889
protected function valueToDateTime($date)
    {
        if (!$date instanceof \DateTime) {
            $date = is_int($date) ? \DateTime::createFromFormat('U', $date) : new \DateTime((string)$date);
        }
        
        return $date;
    }
442891
public function formatDateTimeUtc(\DateTime $date = null)
    {
        if (null === $date) {
            return null;
        }

        $date->setTimezone(new \DateTimeZone('UTC'));

        return $date->format("Y-m-d\TH:i:s\Z");
    }
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));
    }
1310154
public function formatDiff(DateTimeInterface $from, DateTimeInterface $to)
    {
        static $units = array(
            'y' => 'year',
            'm' => 'month',
            'd' => 'day',
            'h' => 'hour',
            'i' => 'minute',
            's' => 'second'
        );

        $diff = $to->diff($from);

        foreach ($units as $attribute => $unit) {
            $count = $diff->$attribute;
            if (0 !== $count) {
                return $this->doGetDiffMessage($count, $diff->invert, $unit);
            }
        }

        return $this->getEmptyDiffMessage();
    }
316426
public function dateAgoInWords(DateTimeInterface $date, array $options = [])
    {
        $options = $this->_options($options, FrozenDate::class);
        if ($options['timezone'] && $date instanceof ChronosInterface) {
            $date = $date->timezone($options['timezone']);
        }

        $now = $options['from']->format('U');
        $inSeconds = $date->format('U');
        $backwards = ($inSeconds > $now);

        $futureTime = $now;
        $pastTime = $inSeconds;
        if ($backwards) {
            $futureTime = $inSeconds;
            $pastTime = $now;
        }
        $diff = $futureTime - $pastTime;

        if (!$diff) {
            return __d('cake', 'today');
        }

        if ($diff > abs($now - (new FrozenDate($options['end']))->format('U'))) {
            return sprintf($options['absoluteString'], $date->i18nFormat($options['format']));
        }

        $diffData = $this->_diffData($futureTime, $pastTime, $backwards, $options);
        list($fNum, $fWord, $years, $months, $weeks, $days) = array_values($diffData);

        $relativeDate = [];
        if ($fNum >= 1 && $years > 0) {
            $relativeDate[] = __dn('cake', '{0} year', '{0} years', $years, $years);
        }
        if ($fNum >= 2 && $months > 0) {
            $relativeDate[] = __dn('cake', '{0} month', '{0} months', $months, $months);
        }
        if ($fNum >= 3 && $weeks > 0) {
            $relativeDate[] = __dn('cake', '{0} week', '{0} weeks', $weeks, $weeks);
        }
        if ($fNum >= 4 && $days > 0) {
            $relativeDate[] = __dn('cake', '{0} day', '{0} days', $days, $days);
        }
        $relativeDate = implode(', ', $relativeDate);

        // When time has passed
        if (!$backwards) {
            $aboutAgo = [
                'day' => __d('cake', 'about a day ago'),
                'week' => __d('cake', 'about a week ago'),
                'month' => __d('cake', 'about a month ago'),
                'year' => __d('cake', 'about a year ago')
            ];

            return $relativeDate ? sprintf($options['relativeString'], $relativeDate) : $aboutAgo[$fWord];
        }

        // When time is to come
        if ($relativeDate) {
            return $relativeDate;
        }
        $aboutIn = [
            'day' => __d('cake', 'in about a day'),
            'week' => __d('cake', 'in about a week'),
            'month' => __d('cake', 'in about a month'),
            'year' => __d('cake', 'in about a year')
        ];

        return $aboutIn[$fWord];
    }
502388
public static function date($date)
    {
        $d = explode('/', date('j/n/Y', strtotime($date)));
        if ($d[0] == '1') {
            $d[0] .= 'º';
        }
        $d[1] = self::MONTHS[$d[1] - 1];
        return implode(' de ', $d);
    }