Sets creation date.

@param \DateTime $created Current date time by default

@return \BackBee\ClassContent\AbstractContent The current instance
@codeCoverageIgnore
335504
public function setCreated(\DateTime $created = null)
    {
        $this->_created = null === $created ? new \DateTime() : $created;

        return $this->getContentInstance();
    }
900764
public function setModified($modified = null)
    {
        if ($modified) {
            $this->modified = $modified;
        } else {
            $this->modified = new \Datetime();
        }

        return $this;
    }
641113
public function setDate(\DateTime $dateTime)
    {
        $this->set(Config::T540, $dateTime->format('Ymd'));

        return $this;
    }
881623
public function setCurrentDate()
    {
        $this->defaultValue = Carbon::now()->timezone($this->getTimezone())->format($this->getFormat());

        return $this;
    }
446615
public function setBirthDate(DateTime $birthDate)
    {
        $this->_setField(self::$BIRTH_DATE, $birthDate->format(self::$BIRTH_DATE_FORMAT));

        return $this;
    }
679644
public function setUpdatedAtValue(\DateTime $updatedAt = null)
    {
        if($updatedAt==null && $this->updatedAt == null){
            $this->updatedAt = new \DateTime();
        }else if($updatedAt instanceof \DateTime){
            $this->updatedAt = $updatedAt;
        }else{
            $this->updatedAt = new \DateTime();
        }
    }
1223007
public function setReferenceTime(\DateTimeInterface $dateTime)
    {
        $dt = $dateTime->format(DATE_ISO8601);
        $this->add('reference_time', $dt);
    }
449980
public function setDateOfBirth($dateOfBirth)
    {
        if (!($dateOfBirth instanceof \DateTime)) {
            //We validate it against a "good" format
            if (1 === preg_match(self::REGEX_DATE_FORMAT, trim($dateOfBirth))) {
                $dateOfBirth = new \DateTime($dateOfBirth);
            } else {
                $dateOfBirth = null;
            }
        }

        $this->dateOfBirth = $dateOfBirth;

        return $this;
    }
1071867
public function setDateAdd(\DateTime $date_add = null)
    {
        $this->date_add = $date_add ? clone $date_add : $date_add;

        return $this;
    }
439983
public function setStart(DateTime $start)
    {
        if ($this->end && $start > $this->end) {
            throw new EventException(
                'New start comes after the end!',
                EventException::INVALID_DATES
            );
        }
        $this->start = clone $start;
        return $this;
    }
1359543
public function getCreated()
    {
        $rtn    = $this->data['created'];

        if (!empty($rtn)) {
            $rtn    = new \DateTime($rtn);
        }
        
        return $rtn;
    }
387552
public function setStartDate(\DateTime $startDate)
    {
        $this->startDate = $startDate
            ->setTimezone(new \DateTimeZone('UTC'))
            ->setTime(0, 0, 0);

        return $this;
    }
691370
public static function createDateFromDateTime(DateTime $dateTime, DateTimeZone $dateTimeZone = NULL) {
    $openYLocaleDate = new OpenYLocaleDate();
    $openYLocaleDate->setDateFromDateTime($dateTime, $dateTimeZone);
    return $openYLocaleDate;
  }
332395
public function setMax(string $max) : Datetime
    {
        $max = date($this->format, strtotime($max));
        $this->attributes['max'] = $max;
        return $this->addTest('max', function ($value) use ($max) {
            return $value <= $max;
        });
    }
128494
public function setDateTime(DateTime $date)
    {
        $this->setYear((int)$date->format('Y'));
        $this->setMonth((int)$date->format('m'));
        $this->setDay((int)$date->format('d'));

        return $this;
    }
838682
protected function createDateTime($timestamp)
    {
        $dateTime = new \DateTime();
        $dateTime->setTimestamp($timestamp);
        $dateTime->setTimezone($this->dateTimeZone);

        return $dateTime;
    }
480422
public function getDatetimeObject($datetime = null)
    {
        if ($datetime instanceof DateTimeInterface) {
            return $datetime;
        }

        if (is_integer($datetime)) {
            $datetime = date('Y-m-d H:i:s', $datetime);
        }

        return new DateTime($datetime);
    }