public function formatCldr($date, $cldrFormat, $locale = null)
    {
        if ($date === 'now') {
            $date = new \DateTime();
        } elseif (is_int($date)) {
            $timestamp = $date;
            $date = new \DateTime();
            $date->setTimestamp($timestamp);
        } elseif (!$date instanceof \DateTimeInterface) {
            throw new \InvalidArgumentException('The given date "' . $date . '" was neither an integer, "now" or a \DateTimeInterface instance.');
        }
        if (empty($cldrFormat)) {
            throw new \InvalidArgumentException('CLDR date formatting parameter not passed.');
        }
        if ($locale === null) {
            $useLocale = $this->localizationService->getConfiguration()->getCurrentLocale();
        } else {
            $useLocale = new Locale($locale);
        }
        return $this->datetimeFormatter->formatDateTimeWithCustomPattern($date, $cldrFormat, $useLocale);
    }
public function formatCldr($date, $cldrFormat, $locale = null)
    {
        if ($date === 'now') {
            $date = new \DateTime();
        } elseif (is_int($date)) {
            $timestamp = $date;
            $date = new \DateTime();
            $date->setTimestamp($timestamp);
        } elseif (!$date instanceof \DateTimeInterface) {
            throw new \InvalidArgumentException('The given date "' . $date . '" was neither an integer, "now" or a \DateTimeInterface instance.');
        }
        if (empty($cldrFormat)) {
            throw new \InvalidArgumentException('CLDR date formatting parameter not passed.');
        }
        if ($locale === null) {
            $useLocale = $this->localizationService->getConfiguration()->getCurrentLocale();
        } else {
            $useLocale = new Locale($locale);
        }
        return $this->datetimeFormatter->formatDateTimeWithCustomPattern($date, $cldrFormat, $useLocale);
    }
public function formatCldr ( $ date , $ cldrFormat , $ locale = null ) { if ( $ date === 'now' ) { $ date = new \ DateTime ( ) ; } elseif ( is_int ( $ date ) ) { $ timestamp = $ date ; $ date = new \ DateTime ( ) ; $ date -> setTimestamp ( $ timestamp ) ; } elseif ( ! $ date instanceof \ DateTimeInterface ) { throw new \ InvalidArgumentException ( 'The given date "' . $ date . '" was neither an integer, "now" or a \DateTimeInterface instance.' ) ; } if ( empty ( $ cldrFormat ) ) { throw new \ InvalidArgumentException ( 'CLDR date formatting parameter not passed.' ) ; } if ( $ locale === null ) { $ useLocale = $ this -> localizationService -> getConfiguration ( ) -> getCurrentLocale ( ) ; } else { $ useLocale = new Locale ( $ locale ) ; } return $ this -> datetimeFormatter -> formatDateTimeWithCustomPattern ( $ date , $ cldrFormat , $ useLocale ) ; }
Format a date to a string with a given cldr format

@param integer|string|\DateTime $date
@param string $cldrFormat Format string in CLDR format (see http://cldr.unicode.org/translation/date-time)
@param null|string $locale String locale - example (de|en|ru_RU)
@return string
Format a date to a string with a given cldr format