date-poll-api/src/Traits/TimeStampableTraitTrait.php

29 lines
528 B
PHP
Executable File

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