returns formatted date/time string for end date

@param   string                   $format    format, see http://php.net/date
@param   \stubbles\date\TimeZone  $timeZone  target time zone of formatted string
@return  string
@since   3.5.0
180968
public function formatEnd(string $format, TimeZone $timeZone = null): string
    {
        return $this->end->format($format, $timeZone);
    }
717374
public function date($date, $format = null)
    {
        if ($this->isEmptyDate($date)) {
            return '';
        }

        $isLocalizerFormat = in_array($format, [Localizer::SHORT, Localizer::LONG, Localizer::VERBOSE]);

        if ($format && !$isLocalizerFormat) {
            return $this->toDateTime($date)->format($format);
        }

        if (!$this->localizer) {
            return $this->toDateTime($date)->format('Y-m-d');
        }

        return $this->localizer->date($date, $format ?: Localizer::SHORT);
    }
1170396
public function format($dateTime, $format = null, $timezone = null)
	{
		// Do string replacements for date format options that can be translated.
		$format = preg_replace('/(^|[^\\\])D/', "\\1" . self::DAY_ABBR, $format);
		$format = preg_replace('/(^|[^\\\])l/', "\\1" . self::DAY_NAME, $format);
		$format = preg_replace('/(^|[^\\\])M/', "\\1" . self::MONTH_ABBR, $format);
		$format = preg_replace('/(^|[^\\\])F/', "\\1" . self::MONTH_NAME, $format);


		// Clone to allow timezone operations
		if ($dateTime instanceof \DateTime)
		{
			$dateTimeInZone = clone $dateTime;
		}
		// Or create from string
		else
		{
			$dateTimeInZone = new \DateTime($dateTime);
		}

		// Set timezone string argument
		if ($timezone instanceof \DateTimeZone)
		{
			$dateTimeInZone->setTimeZone($timezone);
		}
		// Set timezone DateTimeZone argument
		else if (is_string($timezone))
		{
			$dateTimeInZone->setTimeZone(new \DateTimeZone($timezone));
		}
		// Or global class option
		else
		{
			$dateTimeInZone->setTimeZone($this->timezone);
		}


		// Format to string
		$return = $dateTimeInZone->format($format ?: $this->format);


		// Manually modify the month and day strings in the formatted time.
		if (strpos($return, self::DAY_ABBR) !== false)
		{
			$return = str_replace(self::DAY_ABBR, $this->dayToString($dateTimeInZone->format('w'), true), $return);
		}

		if (strpos($return, self::DAY_NAME) !== false)
		{
			$return = str_replace(self::DAY_NAME, $this->dayToString($dateTimeInZone->format('w')), $return);
		}

		if (strpos($return, self::MONTH_ABBR) !== false)
		{
			$return = str_replace(self::MONTH_ABBR, $this->monthToString($dateTimeInZone->format('n'), true), $return);
		}

		if (strpos($return, self::MONTH_NAME) !== false)
		{
			$return = str_replace(self::MONTH_NAME, $this->monthToString($dateTimeInZone->format('n')), $return);
		}


		return $return;
	}
790629
public function getDisplayDateTime($input, $format = null, $timezone = null)
    {
        return \enpii\enpiiCms\helpers\DateTimeHelper::fromDbFormat($input,
            ($format === null ? $this->datetimeFormat : $format),
            ($timezone === null ? $this->timezone : $timezone));
    }
1336896
public function i18n(string $format = '', int $time = 0, bool $utc = false): string
    {
        if (!$format) {
            $format = get_option('date_format');
            $format .= ' '.get_option('time_format');
            $format = $this->c::mbTrim($format);
        }
        $time = $time ? abs($time) : time(); // UTC time.

        // If UTC enabled, leave `$time` as-is.
        // Otherwise, convert it to a local timestamp.
        // This is necessary because `date_i18n()` doesn't do the conversion.
        // The `date_i18n()` function only works w/UTC (by default), if no `$time` is given.
        $time = $utc ? $time : $this->toLocal($time); // Adjusted time, based on `$utc` param.

        if ($utc && preg_match('/(?<!\\\\)[PIOTZe]/u', $format)) {
            // If UTC is enabled and the date format includes a TZ char.
            // Necessary, because `date_i18n()` doesn't handle this properly.
            // `date_i18n()` translates TZ chars into a local timezone regardless.

            // So here, we escape TZ chars and then apply them in UTC.
            $format = preg_replace('/(?<!\\\\)([PIOTZe])/u', '#\\\\${1}', $format);
            return preg_replace_callback('/(#)([PIOTZe])/u', function ($m) use ($time) {
                return gmdate($m[2], $time); // UTC-based TZ chars.
            }, date_i18n($format, $time, $utc));
        }
        return date_i18n($format, $time, $utc);
    }
188569
public static function createFromFormat($format, $time, $timezone = null)
    {
        if ($timezone === null) {
            $timezone = new DateTimeZone(date_default_timezone_get());
        }

        $datetime = \DateTime::createFromFormat($format, $time, $timezone);

        return new self($datetime->format(DateTime::ISO8601), $timezone);
    }
1054447
public function format(string $format): string
    {
        return CommonTime::inSeconds($this->seconds)->format($format);
    }
279363
public function time(string $format, \DateTimeZone $timeZone = null) : DateFieldBuilder
    {
        return $this->dateTypeBuilder(new TimeOfDayType($format, $timeZone));
    }
754308
public static function now(string $format = 'Y-m-d H:i:s', string $timezone = null): string
    {
        return self::factory(null, $timezone)->format($format);
    }
31441
public function format($format = '')
  {
    if ( !empty($format) ){
      return $this->time->format($format);
    }
    else { 
      return $this->time->format('Y-m-d H:i:s');
    }
  }
534309
public function getDate($format = null)
    {
        $format = empty($format) ? $this->format : $format;

        return strftime($format, $this->ts);
    }
709830
public function datetime(string $format, \DateTimeZone $timeZone = null) : DateFieldBuilder
    {
        return $this->dateTypeBuilder(new DateTimeType($format, $timeZone));
    }
327866
public function convertTo(string $zone, string $format = null)
    {
        $time = $this->time + $this->calculateOffset($zone);

        if (!is_null($format)) {
            return date($format, $time);
        }

        return $time;
    }
416646
public static function _utcDate ($format = 'Y-m-d H:i:s', $time = FALSE)
	{
		return $time? gmdate ($format, $time) : gmdate ($format);
	}
343655
public static function format($time = null, $format = 'Y-m-d H:i:s') {
		if (!empty($time) && !is_numeric($time)) {
			$format = $time;
			$time = time();
		}
		if (is_null($time)) {
			$time = time();
		}
		return date($format, $time);
	}
372607
public static function formatDate($format, $timestamp)
    {
        static $datesPatterns = null;
        static $timesPatterns = null;

        if ($datesPatterns === null || $timesPatterns === null) {
            $datesPatterns = "/\b(" . implode('|', array_keys(static::$_map['date'])) . ")\b(?![^']*'(?:(?:[^']*'){2})*[^']*$)/i";
            $timesPatterns = "/\b(" . implode('|', array_keys(static::$_map['time'])) . ")\b(?![^']*'(?:(?:[^']*'){2})*[^']*$)/i";
        }

        // normalize formats
        $result = preg_replace_callback($datesPatterns, function ($matches) use ($timestamp) {
            return date(static::$_map['date'][$matches[1]], $timestamp);
        }, trim($format));

        $result = preg_replace_callback($timesPatterns, function ($matches) use ($timestamp) {
            return date(static::$_map['time'][$matches[1]], $timestamp);
        }, $result);

        return str_replace('\'', '', $result);
    }
532052
public static function createFromFormat($format, $time, $timezone = null)
    {
        if (null === $timezone) {
            $timezone = self::getServerTimezone();
        }

        if (null === $timezone) {
            // This is necessary due to how native DateTime handles passing null for a timezone (it doesnt)
            $parent = parent::createFromFormat($format, $time);
        } else {
            $parent = parent::createFromFormat($format, $time, $timezone);
        }

        if (empty($parent)) {
            throw new TypeException('Could not create DateTime from the given format');
        }

        $datetime = new self('@' . $parent->getTimestamp());
        if (null !== $timezone) {
            $datetime->setTimezone($timezone);
        }

        return $datetime;
    }