29 $entity = \DateTime::createFromFormat($format, $date);
31 if ($entity && $entity->getTimeZone()->getName() ===
'Z')
38 return new self(
new Type\DateTime($entity->format($format), $format, $timeZone), $format);
52 return new self(
new Type\Date($date, $format), $format);
63 $this->
format = $dateFormat
65 ? Type\Date::convertFormatToPhp(FORMAT_DATETIME)
66 : Type\Date::convertFormatToPhp(FORMAT_DATE)
76 'date' => $this->date->format($this->
format),
77 'timezone' => ($this->date instanceof
Type\DateTime) ? $this->date->getTimeZone()->getName() :
null,
86 return $this->date->format($this->
format);
97 $this->date->setTimeZone($timeZone);
107 public function format(
string $format =
null): string
109 return $this->date->format($format ?? $this->
format);
120 $object = clone $this;
121 $object->date->
add($addTime);
131 return $this->date->getTimestamp();
140 public function sub(
string $subtractTime):
Date
142 $object = clone $this;
143 $object->date->
add(
"-{$subtractTime}");
153 $this->date = clone $this->date;
162 public function setTime(
int $hour,
int $minutes,
int $seconds):
Date
166 $this->date->
setTime($hour, $minutes, $seconds);
201 return (
int)$this->date->format(
'H');
209 return (
int)$this->date->format(
'i');
217 return (
int)$this->date->format(
's');
225 return (
int)$this->date->format(
'm');
233 return (
int)$this->date->format(
'd');
241 return (
int)$this->date->format(
'Y');
268 return $this->format;
format(string $format=null)
setTime(int $hour, int $minutes, int $seconds)
static createDateTimeFromFormat(string $date, string $format)
setTimezone(DateTimeZone $timeZone)
__construct(Type\Date $date=null, string $dateFormat=null)
setDateTimeFormat(string $format)
static createDateFromFormat(string $date, string $format)
sub(string $subtractTime)
static getDateObject(string $date=null, ?bool $fullDay=true, ?string $tz='UTC')