@param string $format formats the date to the specific format, null returns DateTime

@return \DateTime|string
180177
public function getProcuredAt($format = 'Y-m-d')
    {
        if ($this->procuredAt instanceof \DateTime && $format !== null) {
            return $this->procuredAt->format($format);
        }

        return $this->procuredAt;
    }
1075641
public function getTime($format = null)
    {
        //argument 1 must be a string or null
        Argument::i()->test(1, 'string', 'null');

        $time = $this->time + $this->offset;

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

        return $time;
    }
93549
public function format($format)
	{
		$replace = array();

		// Loop all format characters and check if we can translate them.
		for ($i = 0; $i < strlen($format); $i++)
		{
			$character = $format[$i];

			// Check if we can replace it with a translated version.
			if (in_array($character, array('D', 'l', 'F', 'M')))
			{
				switch ($character)
				{
					case 'D':
						$key = $this->datetime->format('l');
						break;
					case 'M':
						$key = $this->datetime->format('F');
						break;
					default:
						$key = $this->datetime->format($character);
				}

				$original = $this->datetime->format($character);
				$translated = $this->getTranslator()->get(strtolower($key));

				// Short notations.
				if (in_array($character, array('D', 'M')))
				{
					$translated = substr($translated, 0, 3);
				}

				// Add to replace list.
				if ($translated && $original != $translated)
				{
					$replace[$original] = $translated;
				}
			}
		}

		// Replace translations.
		if ($replace)
		{
			return str_replace(array_keys($replace), array_values($replace), $this->datetime->format($format));
		}

		return $this->datetime->format($format);
	}
456488
public static function renderDateTime(DateTime $dateTime = null, $format = self::DATETIME_FORMAT) {
        if (null === $dateTime) {
            return "";
        }
        return $dateTime->format($format);
    }
383916
public function formatDate(DateTime $dateTime = null, $format = DateTimeRenderer::DATETIME_FORMAT) {
        return DateTimeRenderer::renderDateTime($dateTime, $format);
    }
1308292
public function getCreatedAt($format = 'Y-m-d H:i:s')
    {
        if ($this->createdAt instanceof \DateTime && $format !== null) {
            return $this->createdAt->format($format);
        }

        return $this->createdAt;
    }
717796
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'));
    }
563313
public function getServerDate($format = null)
    {
        $node = $this->getFirst('//epp:epp/epp:greeting/epp:svDate');
        if ($format === null) {
            return $node->nodeValue;
        }

        return date_create_from_format($format, $node->nodeValue);
    }
491836
public function getCreatedTime($format = "")
    {
        $time = $this->created_time;
        if (!empty($format)) {
            $timestamp = strtotime($time);
            $time      = date($format, $timestamp);
        }

        return $time;
    }
592649
public function format($format)
    {
        $timestamp = mktime(
            $this->hour,
            $this->minute,
            $this->second,
            $this->month,
            $this->day,
            $this->year
        );
        return strftime($format, $timestamp);
    }
469793
public function Format($format)
    {
        if (!$this->value) {
            return null;
        }
        $formatter = $this->getFormatter();
        $formatter->setPattern($format);
        return $formatter->format($this->getTimestamp());
    }
99794
protected function parse_format($format) {
		$format = parent::parse_format($format);
		return str_replace(array_keys(static::$days), static::$days, $format);
	}
840655
static public function udate($format)
	{
		$utimestamp = microtime(true);

		$usec = round(1000 * 1000 * ($utimestamp - floor($utimestamp)));

		return date(str_replace('u', $usec, $format), $utimestamp);
	}
558208
public function format(string $format)
    {
        $result = '';
        $length = \mb_strlen($format);

        $skip_next = false;

        // iterate for each character
        for ($index = 0; $index < $length; $index++) {
            $format_char = mb_substr($format, $index, 1);

            $result .= $this->getValueOfFormatCharacter($format_char, $skip_next);
        }

        // remove null bits if they exist
        return str_replace("\0", '', $result);
    }
1095704
public function date($date, $format = null)
	{
		$datetime = DateTimeUtil::getDateTime($date);
        if (empty($format)) {
			$format = $this->cfg['date_format'];
		}
		if ($format == 'rel') {
			$date = DateTimeUtil::getRelTime($datetime);
		} else {
			$date = $datetime->format($format);
		}
		return $date;
	}
640913
public function format($format)
    {
        try {
            return $this->getDateObject()->format($format);
        } catch (\Exception $e) {
            throw new DateTimeObjectException(DateTimeObjectException::MSG_INVALID_DATE_FORMAT, [$format]);
        }
    }
87695
public static function normalizeFormat($format)
    {
        static $datesPatterns = null;
        static $timesPatterns = null;

        if ($datesPatterns === null || $timesPatterns === null) {
            $datesPatterns = '/(' . implode('|', array_keys(static::$_map['date'])) . ')/';
            $timesPatterns = '/(' . implode('|', array_keys(static::$_map['time'])) . ')/';
        }

        $format = trim($format);
        $format = preg_replace("/'([^']+)'/", '', $format); // remove quotes
        $format = preg_replace('/\s{2,}/', ' ', $format); // remove double spaces
        $format = trim($format);
        list($dateFormat, $timeFormat) = explode(' ', "{$format} ");

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

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

        $format = trim($dateFormat . ' ' . $timeFormat);

        return $format;
    }