29 lines
560 B
PHP
29 lines
560 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Traits;
|
||
|
|
||
|
use DateTimeInterface;
|
||
|
use Doctrine\ORM\Mapping as ORM;
|
||
|
use PhpParser\Node\Scalar\String_;
|
||
|
|
||
|
trait TimeStampableTrait {
|
||
|
/**
|
||
|
* @ORM\Column(type="datetime" , options={"default"="CURRENT_TIMESTAMP"})
|
||
|
*/
|
||
|
private $createdAt;
|
||
|
|
||
|
public function getCreatedAt(): ?DateTimeInterface {
|
||
|
return $this->createdAt;
|
||
|
}
|
||
|
public function getCreatedAtAsString(): string {
|
||
|
return $this->createdAt->format('c');
|
||
|
}
|
||
|
|
||
|
public function setCreatedAt( DateTimeInterface $createdAt ): self {
|
||
|
$this->createdAt = $createdAt;
|
||
|
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
}
|