public function format($format = 'date', $timestamp = null)
    {
        $timestamp = is_numeric($timestamp) ? '@'.intval($timestamp) : $timestamp;
        $timestamp = is_a($timestamp, 'DateTime') ? $timestamp : new DateTime($timestamp);

        $key = $this->getTranslationKey("date.formats.{$format}");
        $format = $this->translator->has($key) ? $this->translator->get($key) : null;

        if (is_null($format)) {
            throw new \InvalidArgumentException('Date format is invalid or does not exists in current language');
        }

        return strftime($format, $timestamp->format('U'));
    }
public function format($format = 'date', $timestamp = null)
    {
        $timestamp = is_numeric($timestamp) ? '@'.intval($timestamp) : $timestamp;
        $timestamp = is_a($timestamp, 'DateTime') ? $timestamp : new DateTime($timestamp);

        $key = $this->getTranslationKey("date.formats.{$format}");
        $format = $this->translator->has($key) ? $this->translator->get($key) : null;

        if (is_null($format)) {
            throw new \InvalidArgumentException('Date format is invalid or does not exists in current language');
        }

        return strftime($format, $timestamp->format('U'));
    }
public function format ( $ format = 'date' , $ timestamp = null ) { $ timestamp = is_numeric ( $ timestamp ) ? '@' . intval ( $ timestamp ) : $ timestamp ; $ timestamp = is_a ( $ timestamp , 'DateTime' ) ? $ timestamp : new DateTime ( $ timestamp ) ; $ key = $ this -> getTranslationKey ( "date.formats.{$format}" ) ; $ format = $ this -> translator -> has ( $ key ) ? $ this -> translator -> get ( $ key ) : null ; if ( is_null ( $ format ) ) { throw new \ InvalidArgumentException ( 'Date format is invalid or does not exists in current language' ) ; } return strftime ( $ format , $ timestamp -> format ( 'U' ) ) ; }
Format a timestamp based on translation

@param  mixed $timestamp    accepts string, unix timestamp and DateTime object
@param  string $format
@return string
Format a timestamp based on translation