public function __get(string $name)
{
switch ($name) {
case 'sql':
return $this->dateTime->format(\DateTime::ISO8601);
case 'email':
return $this->dateTime->format(\DateTime::RFC822);
case 'web':
return $this->dateTime->format(\DateTime::W3C);
case 'cookie':
return $this->dateTime->format(\DateTime::COOKIE);
case 'rss':
return $this->dateTime->format(\DateTime::RSS);
case 'unix':
// Returns false if the stored date/time has no valid unix timestamp representation
return $this->dateTime->getTimestamp();
case 'http':
$this->setTemporaryTimeZone('GMT');
$result = $this->dateTime->format('D, d M Y H:i:s') . ' GMT';
$this->revertOriginalTimeZone();
return $result;
case 'extended':
return $this->formatExtended();
case 'interval':
return $this->formatAsInterval();
case 'full':
if ((int) $this->dateTime->diff(new \DateTime())->format('%y%m%d%h') > 0) {
// If the difference between now and the stored date/time if greater than one hour
return $this->formatExtended();
} else {
return $this->formatAsInterval();
}
default:
throw new \InvalidArgumentException(sprintf('Unknown format %s.', $name));
}
}