Set new date.

@param \DateTimeInterface $date Date and time.

@since 1.0
979980
public function setDate(\DateTimeInterface $date)
    {
        $this->getDomElement()->nodeValue = $date->format(\DateTime::RFC3339);
        $this->setCachedProperty('content', $date);
    }
305291
public function setDateTime(DateTimeInterface $dt)
    {
        $tz = $dt->getTimeZone();
        $isUtc = in_array($tz->getName(), ['UTC', 'GMT', 'Z']);

        if ($isUtc) {
            $value = $dt->format('Ymd\\THis\\Z');
        } else {
            // Calculating the offset.
            $value = $dt->format('Ymd\\THisO');
        }

        $this->value = $value;
    }
682528
public function setEndDate($endDate): void
    {
        if (is_string($endDate)) {
            $endDate = new Time($endDate);
        }

        $this->endDate = $endDate;
    }
456980
public function setDate(\DateTime $date): void
    {
        $this->getFileElement()->setAttributeNS(static::XLIFF_NS, 'date', $date->format(\DateTime::ATOM));
    }
170882
public function setEndDate($date)
    {
        $date = AnDomainAttributeDate::getInstance()->setDate($date);
        $this->set('endDate', $date);

        return $this;
    }
435669
public function setCreated( $date, $format = null )
    {
        $this->created = $this->inputDate( $date, $format );
        return $this;
    }
1075940
public function toDate($date)
	{
		$this->current = (is_string($date) ? new \DateTime($date, self::$utc) : $date);
	}
980064
public function setDateEnd( $date )
	{
		if ( $date == $this->getDateEnd() ) { return; }

		$this->_checkDateFormat($date);

		$this->_values['end'] = ( $date !== null ? (string) $date : null );

		$this->setModified();
	}
633093
public function setTimeFrom($date = null)
    {
        $date = $this->resolveCarbon($date);

        return $this->setTime($date->hour, $date->minute, $date->second, $date->microsecond);
    }
424675
public function setDate(DateTimeInterface $dateTime)
    {
        if (!$this->setHeaderFieldModel('Date', $dateTime)) {
            $this->getHeaders()->addDateHeader('Date', $dateTime);
        }

        return $this;
    }
1142173
public function setCommand($date, $time)
    {
        $arguments = $this->arguments->getValues();
        if (count($arguments) === 1) {
            $str = trim(strtr($arguments[0], 'Tt', '  '));
            if (strpos($str, ' ') === false) {
                if (strpos($str, ':') !== false) {
                    $date = '';
                    $time = $str;
                } else {
                    $date = $str;
                    $time = '';
                }
            } else {
                list($date, $time) = explode(' ', $str);
            }
        }

        $date = $date ? strtr($date, '/', '-') : (string)date('Y-m-d');
        $date = trim(trim($date), '-');

        switch (substr_count($date, '-')) {
            case 0:
                $date = date('Y-m-') . $date;
                break;
            case 1:
                $date = date('Y-') . $date;
                break;
        }
        $parts = explode('-', $date);
        $parts[0] = substr(date('Y'), 0, 4 - strlen($parts[0])) . $parts[0];
        $date = $parts[0] . '-' . str_pad($parts[1], 2, '0', STR_PAD_LEFT) . '-' . str_pad($parts[2], 2, '0', STR_PAD_LEFT);

        $time = $time ? trim($time) : (string)date('H:i:s');
        if ($time[0] === ':') {
            $time = date('H') . $time;
        }
        switch (substr_count($time, ':')) {
            case 0:
                $time .= date(':i:s');
                break;
            case 1:
                $time .= date(':s');
                break;
        }
        $parts = explode(':', $time);

        $time = str_pad($parts[0], 2, '0', STR_PAD_LEFT) . ':' . str_pad($parts[1], 2, '0', STR_PAD_LEFT) . ':' . str_pad($parts[2], 2, '0', STR_PAD_LEFT);

        $str = $date . ' ' . $time;
        $timestamp = strtotime($str);
        if ($timestamp === false || preg_match('#^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$#', $str) !== 1) {
            return $this->console->error(['`:time` time format is invalid', 'time' => $str]);
        } else {
            $this->_updateDate($timestamp);
            $this->console->writeLn(date('Y-m-d H:i:s'));

            return 0;
        }
    }
727746
public function setDatePayment( $date )
	{
		if ( $date === $this->getDatePayment() ) { return; }

		$this->_checkDateFormat($date);

		$this->_values['datepayment'] = (string) $date;
		$this->setModified();
	}
1187000
public static function createFromDateTime(DateTimeInterface $dateTime): self
    {
        $utcTimestamp = $dateTime->getTimestamp();

        // yes, PHP DateTime can accept integer timestamp only as a string ¯\_( ͡° ͜ʖ ͡°)_/¯
        $result = (new self("@$utcTimestamp"))->setTimezone($dateTime->getTimezone());

        return $result;
    }
486204
protected function serializeDate(\DateTimeInterface $date)
    {
        if ($date instanceof Carbon && $this->timestamp_get_with_user_timezone) {
            $date->setTimezone($this->getAuthUserDateTimezone());
        }
        return $date->format($this->getDateFormat());
    }
709889
protected function valueToDateTime($date)
    {
        if (!$date instanceof \DateTime) {
            $date = is_int($date) ? \DateTime::createFromFormat('U', $date) : new \DateTime((string)$date);
        }
        
        return $date;
    }
484014
public function getDate(\DateTimeInterface $dateTime)
    {
        $date = new Date($dateTime);
        $this->loadDay($date);

        return $date;
    }
1303430
final public static function cloneDateTime($date)
    {
        try {
            $result = new \DateTimeImmutable();
            return $result->setTimezone($date->getTimezone())->setTimestamp($date->getTimestamp());
        } catch (\Exception $e) {
            return null;
        }
    }