ze-ph.DateTime.php.mustache Maven / Gradle / Ivy
format(static::DATE_TIME_FORMAT);
}
return $result;
}
/**
* @inheritDoc
*/
public function hydrate($arrayValue, $objectValue, array $array = null)
{
$result = null;
if (!empty($arrayValue)) {
$date = $this->parseDateString($arrayValue);
if ($date instanceof \DateTime) {
$result = $date;
}
}
return $result;
}
/**
* @param $arrayValue
* @return \DateTime
*/
protected function parseDateString($arrayValue)
{
return \DateTime::createFromFormat(static::DATE_TIME_FORMAT, $arrayValue, new \DateTimeZone('UTC'));
}
}