return current date

@param string $format optionnal date format

@return \DateTime
516750
public function now($format = null)
    {
        $date = $this->currentDate
            ? clone $this->currentDate
            : ($this->currentDate = new \DateTime())
        ;

        return empty($format) ?
            $date :
            $date->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');
    }
  }
215105
protected function getDateTimeWithOptionalFormat( $format, $value )
	{
		$date = DateTime::createFromFormat( $format, $value );

		if ( $date )
		{
			return $date;
		}

		try
		{
			return new DateTime( $value );
		}
		catch ( Exception $e )
		{
			//
		}
	}
116598
public function toString(string $format = null): string
    {
        if (isset($format)) {
            return (new DateTime('@0'))
                ->diff(new DateTime('@'.round($this->time, 0)))
                ->format($format);
        }
        return $this->__toString();
    }
1075073
protected function formatDateTime(\DateTime $date = null, $format = null)
    {
        return $date && $format ?
            $date->format($format) :
            $date
        ;
    }
748707
public static function getFormattedDate($date, $format)
    {
        if (StringUtils::isEmpty($date) || StringUtils::isEmpty($format)) {
            return null;
        }

        return date($format, strtotime($date));
    }
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;
	}
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;
    }
950625
public function parseCustomFormat($format)
    {
        if (isset($this->parsedFormats[$format])) {
            return $this->parsedFormats[$format];
        }

        return $this->parsedFormats[$format] = $this->parseFormat($format);
    }
375643
public function getUpdateDate($format = null)
    {
        $node = $this->getFirst('//epp:epp/epp:response/epp:resData/host:infData/host:upDate');
        if ($node === null) {
            return null;
        }

        if ($format === null) {
            return $node->nodeValue;
        }

        return date_create_from_format($format, $node->nodeValue);
    }
412797
public function getTransferDate($format = null)
    {
        $node = $this->getFirst('//epp:epp/epp:response/epp:resData/domain:infData/domain:trDate');
        if ($node === null) {
            return null;
        }

        if ($format === null) {
            return $node->nodeValue;
        }

        return date_create_from_format($format, $node->nodeValue);
    }
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);
    }
1099597
public function setFormat($format)
    {
        $this->format = (string) $format;

        foreach ($this->items as $time) {

            $time->setFormat($format);
        }

        return $this;
    }
1163971
public function getDate($format = null)
    {
        if (empty($format)) {
            return $this->get('__date__')->sec;
        }
        
        return date($format, $this->get('__date__')->sec);
    }
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);
        }
    }
511482
protected function inputDate( $date, $format = null )
    {
        if ( ! $date instanceof DateTime )
        {
            if ( $date instanceof BaseDateTime )
            {
                $date = DateTime::createFromFormat(
                    DateTime::ISO8601,
                    $date->format( DateTime::ISO8601 )
                );
            }

            if ( is_int( $date ) )
            {
                $date = new DateTime( '@' . $date );
            }
            else if ( empty( $format ) )
            {
                $date = new DateTime( $date );
            }
            else
            {
                $date = DateTime::createFromFormat( $format, $date );
            }
        }

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