Format the date, or return its format.

@param  string|null                       $newFormat If string, will set format. If omitted,
will return format
@return string|\Tev\Field\Model\DateField            Format or this, for chaining
12250
public function format($newFormat = null)
    {
        if ($newFormat === null) {
            return $this->format;
        }

        $this->format = $newFormat;

        return $this;
    }
1322307
public function setFormat($format)
    {
        if (!is_null($format)) {
            $this->format = $format;
            $this->useFormat(false);
        }

        return $this;
    }
1222286
public function prettyDate($date, $format = null)
    {
        if (is_string($date)) {
            $date = new \DateTime($date);
        }

        if (null !== $format) {
            return $this->dateFormatter->prettyDate($date, $format);
        }

        return $this->dateFormatter->prettyDate($date);
    }
507069
public static function date_format($format = null)
    {
        if (empty($format)) {
            $format = 'd-M-Y H:i:s O';
        }

        if (strpos($format, 'u') !== false) {
            $dt  = number_format(microtime(true), 6, '.', '');
            $dt .=  '.' . date_default_timezone_get();

            if ($date = date_create_from_format('U.u.e', $dt)) {
                return $date->format($format);
            }
        }

        return date($format);
    }
629389
public function setDisplayFormat($displayFormat)
    {
        if (!in_array($displayFormat, static::FORMATS)) {
            throw new \InvalidArgumentException("bad format '{$displayFormat}'");
        }
        $this->displayFormat = $displayFormat;

        return $this;
    }
318415
protected function formatDate($dateString)
    {
        try {
            // We have to handle timestamps a little differently
            if (is_numeric($dateString) && (int) $dateString == $dateString) {
                $date = DateTime::createFromFormat('U', (int) $dateString, new DateTimeZone('UTC'));
            } else {
                $date = new DateTime($dateString, new DateTimeZone('UTC'));
            }

            return $date->format(DateTime::W3C);
        } catch (\Exception $e) {
            throw new InvalidArgumentException("Malformed last modified date: {$dateString}", 0, $e);
        }
    }
29519
protected function getFormattedDate($input, $inputFormat, $outputFormat, DateTimeZone $timezone)
    {
        $formattedDate = DateTime::createFromFormat($inputFormat, $input, $timezone);
        if ($formattedDate) {
            return $formattedDate->format($outputFormat);
        }

        return $input;
    }
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);
	}
526216
protected function formatDatetimeString($datetime, $format = null)
    {
        $format = $format ?: $this->format;

        if (!$datetime) {
            return null;
        }

        if ($datetime instanceof Carbon) {
            return $datetime->format($format);
        }

        return date($format, strtotime($datetime));
    }
734268
public static function formatOther($timestamp, $format = 'eeee')
    {
        $instance=self::$_instance;
        $fmt=new IntlDateFormatter($instance->_currentLocale, 0, 0);
        $fmt->setPattern($format);
        return $fmt->format($timestamp);
    }
436339
public function format(): Format\Format
    {
        if (null === $this->format) {
            $this->format = Format\Format::fromJson($this);
        }

        return $this->format;
    }
551917
public function dateFormat($date, string $format = 'M d Y'): string
    {
        if ($date instanceof DateTime) {
            return $date->format($format);
        } elseif (is_int($date)) {
            return date($format, $date);
        }

        return date($format, strtotime($date));
    }
657034
public static function timeFormat($timestamp = null, $format = 'Y-m-d H:i:s')
    {
        if ($timestamp === null) {
            $timestamp = time();
        } elseif (empty($timestamp)) {
            return null;
        } else {
            $timestamp = intval($timestamp);
        }
        if (strncmp($format, 'php:', 4) === 0) {
            $format = substr($format, 4);
        }
        
        return date($format, $timestamp);
    }
516750
public function now($format = null)
    {
        $date = $this->currentDate
            ? clone $this->currentDate
            : ($this->currentDate = new \DateTime())
        ;

        return empty($format) ?
            $date :
            $date->format($format)
        ;
    }
681352
public static function DateFormat($format, $date = null)
  {
    if (!empty($date) && !is_int($date)) {
      $date = strtotime($date);
    }

    return strftime($format, $date ?: time());
  }
963459
public static function formatDate($timestamp = null, $style = 'short')
    {
        $property = $style . 'Date';
        return self::date(self::getLocale()->$property, $timestamp);
    }
668362
public static function formatDate($date, $fromFormat='d-m-Y', $toFormat='Y-m-d')
    {   
        $dt = \DateTime::createFromFormat($fromFormat, $date);
        return !$dt ? null : $dt->format($toFormat);
    }