@see http://www.php.net/manual/de/function.date.php
@see http://en.wikipedia.org/wiki/ISO_8601

@param string $format

@return string
177430
public function getShippingCompletedTime($format = '')
    {
        $time = $this->shipping_completed_time;
        if (!empty($format)) {
            $timestamp = strtotime($time);
            $time      = date($format, $timestamp);
        }

        return $time;
    }
1001274
public function getUpdatedAt($format = 'Y-m-d H:i:s')
    {
        if ($this->updatedAt instanceof \DateTime && $format !== null) {
            return $this->updatedAt->format($format);
        }

        return $this->updatedAt;
    }
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;
    }
283977
public function getDateSunday($format = 'Y-m-d')
    {
        $weekDay = 7 - $this->format('N');
        $time = $this->getTimestamp();
        if ($weekDay) {
            $time += $weekDay * 24 * 3600;
        }
        return date($format, $time);
    }
18972
public function date($key, $format = "F j, Y")
    {
        if (is_numeric($this->_params[$key])) {
            return date($format, $this->_params[$key]);
        }

        return date($format, strtotime($this->_params[$key]));
    }
352362
public function format($date, $format)
    {
        if ($date instanceof \DateTimeInterface) {
            return $date->format($format);
        } elseif ($date instanceof \DateInterval) {
            return $date->format($format);
        } elseif ($date === 'now') {
            return date($format);
        } else {
            $timestamp = (integer)$date;
            return date($format, $timestamp);
        }
    }
636255
protected function date($format){

		$timestamp = $this->getTimestamp();
		
	    list($gYear, $gMonth, $gDay, $gWeek) = explode('-', date('Y-m-d-w', $timestamp));
	    list($pYear, $pMonth, $pDay) = static::getJalali($gYear, $gMonth, $gDay);
	    $pWeek = ($gWeek + 1);

	    if ($pWeek >= 7) {
	        $pWeek = 0;
	    }

	    if ($format == '\\') {
	        $format = '//';
	    }

	    $lenghFormat = strlen($format);
	    $i = 0;
	    $result = '';

	    while ($i < $lenghFormat) {
	        $par = $format{$i};
	        if ($par == '\\') {
	            $result .= $format{ ++$i};
	            $i ++;
	            continue;
	        }
	        switch ($par) {
	            # Day
	            case 'd':
	                $result .= sprintf('%02s', $pDay);
	                break;

	            case 'D':
	                $result .= substr(static::$dayWeek[$pWeek], 0, 2);
	                break;

	            case 'j':
	                $result .= $pDay;
	                break;

	            case 'l':
	                $result .= static::$dayWeek[$pWeek];
	                break;

	            case 'N':
	                $result .= $pWeek + 1;
	                break;

	            case 'w':
	                $result .= $pWeek;
	                break;

	            case 'z':
	                $result .= $this->daysYear($pMonth, $pDay);
	                break;

	            case 'S':
	                $result .= self::NUMBER_TH;
	                break;

	            # Week
	            case 'W':
	                $result .= ceil($this->daysYear($pMonth, $pDay) / 7);
	                break;

	            # Month
	            case 'F':
	                $result .= static::$monthYear[$pMonth-1];
	                break;

	            case 'm':
	                $result .= sprintf('%02s', $pMonth);
	                break;

	            case 'M':
	                $result .= substr(static::$monthYear[$pMonth-1], 0, 6);
	                break;

	            case 'n':
	                $result .= $pMonth;
	                break;

	            case 't':
	                $result .= static::isLeapYear($pYear) && ($pMonth == 12) ? 30 : static::$daysMonthJalali[intval($pMonth)-1];
	                break;

	            # Years
	            case 'L':
	                $result .= intval($this->isLeapYear($pYear));
	                break;

	            case 'Y':
	            case 'o':
	                $result .= $pYear;
	                break;

	            case 'y':
	                $result .= substr($pYear, 2);
	                break;

	            # Time
	            case 'a':
	            case 'A':
	                if (date('a', $timestamp) == 'am') {
	                    $result .= (($par == 'a') ? self::AM : self::ANTE_MERIDIEM);
	                } else {
	                    $result .= (($par == 'a') ? self::PM : self::POST_MERIDIEM);
	                }
	                break;

	            case 'B':
	            case 'g':
	            case 'G':
	            case 'h':
	            case 'H':
	            case 's':
	            case 'u':
	            case 'i':
	            # Timezone
	            case 'e':
	            case 'I':
	            case 'O':
	            case 'P':
	            case 'T':
	            case 'Z':
	                $result .= date($par, $timestamp);
	                break;

	            # Full Date/Time
	            case 'c':
	                $result .= ($pYear . '-' . $pMonth . '-' . $pDay . ' ' . date('H:i:s P', $timestamp));
	                break;

	            case 'r':
	                $result .= (substr(static::$dayWeek[$pWeek], 0, 2) . '، ' . $pDay . ' ' . substr(static::$monthYear[$pMonth], 0, 6) . ' ' . $pYear . ' ' . date('H:i:s P', $timestamp));
	                break;

	            case 'U':
	                $result .= $timestamp;
	                break;

	            default:
	                $result .= $par;
	        }
	        $i ++;
	    }

	    return $result;
	}
430347
public function getCode($format)
    {
        foreach ($this->codes as $code) {
            if ($code->getFormat() == $format) {
                return $code;
            }
        }
    }
1261474
protected static function createDateTime(string $date, string $format = 'Y-m-d H:i:s'): \DateTime
    {
        return \DateTime::createFromFormat($format, $date);
    }
60205
public static function format($date = false, $format = 'Y-m-d H:i:s') {

        if($date) {

            $DateTime = new DateTime($date);
            return $DateTime->format($format);
        }

        return false;
    }
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);
    }
254183
protected static function createDate(string $date, string $format = 'Y-m-d'): \DateTime
    {
        return \DateTime::createFromFormat($format, $date);
    }
692725
public function format($format)
    {
        $format = str_replace('%U', sprintf("%06d", $this->u), $format);
        $format = str_replace('%u', sprintf("%d", intval($this->u)), $format);

        return parent::format($format);
    }
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);
    }
234796
protected function convertDateFormatToMoment($format)
    {
        $replacements = [
            'd' => 'DD',
            'D' => 'ddd',
            'j' => 'D',
            'l' => 'dddd',
            'N' => 'E',
            'S' => 'o',
            'w' => 'e',
            'z' => 'DDD',
            'W' => 'W',
            'F' => 'MMMM',
            'm' => 'MM',
            'M' => 'MMM',
            'n' => 'M',
            't' => '', // no equivalent
            'L' => '', // no equivalent
            'o' => 'YYYY',
            'Y' => 'YYYY',
            'y' => 'YY',
            'a' => 'a',
            'A' => 'A',
            'B' => '', // no equivalent
            'g' => 'h',
            'G' => 'H',
            'h' => 'hh',
            'H' => 'HH',
            'i' => 'mm',
            's' => 'ss',
            'u' => 'SSS',
            'e' => 'zz', // deprecated since version 1.6.0 of moment.js
            'I' => '', // no equivalent
            'O' => '', // no equivalent
            'P' => '', // no equivalent
            'T' => '', // no equivalent
            'Z' => '', // no equivalent
            'c' => '', // no equivalent
            'r' => '', // no equivalent
            'U' => 'X',
        ];

        foreach ($replacements as $from => $to) {
            $replacements['\\' . $from] = '[' . $from . ']';
        }

        return strtr($format, $replacements);
    }
1218346
public function getFormattedDate($format, $startDate = true)
    {
        $date = $this->getEndDate();

        // Start date should be formatted?
        if ($startDate) {
            $date = $this->getStartDate();
        }

        // Unknown date or format is invalid?
        // Nothing to do
        if (null === $date || !Date::isValidDateFormat($format)) {
            return '';
        }

        return $date->format($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;
    }