<?php
|
namespace JVBase\managers\SEO\render\DataType;
|
|
if (!defined('ABSPATH')) {
|
exit;
|
}
|
|
final class Date {
|
/**
|
* @var string Time in ISO 8601 format, hh:mm:ss[Z|(+|-)hh:mm]
|
*/
|
protected string $date;
|
|
/**
|
* @throws \DateMalformedStringException
|
*/
|
public function __construct(string $date)
|
{
|
$this->setDate($date);
|
}
|
|
public function getDate():?string {
|
if (!isset($this->date)) {
|
return null;
|
}
|
return $this->date;
|
}
|
|
/**
|
* @throws \DateMalformedStringException
|
*/
|
public function setDate(string $date):void
|
{
|
$time = new \DateTime(strtotime($date));
|
$time = $time->format('c');
|
if ($time){
|
$this->date = $time;
|
}
|
}
|
}
|