for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Artack\Dsn\Field;
class DateField extends AbstractField
{
private $dateTime;
public function __construct(string $name, \DateTimeInterface $date)
parent::__construct($name, null);
$this->setDateTime($date);
}
public function getDateTime(): \DateTimeImmutable
return $this->dateTime;
/**
* If a DateTime instance is provided, it is converted to DateTimeImmutable.
*/
public function setDateTime(\DateTimeInterface $dateTime): void
if ($dateTime instanceof \DateTime) {
$immutable = new \DateTimeImmutable('@'.$dateTime->getTimestamp());
$dateTime = $immutable->setTimezone($dateTime->getTimezone());
$this->dateTime = $dateTime;