public function DateTimeFormatterStrategy::hydrate in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/zendframework/zend-hydrator/src/Strategy/DateTimeFormatterStrategy.php \Zend\Hydrator\Strategy\DateTimeFormatterStrategy::hydrate()
Converts date time string to DateTime instance for injecting to object
Parameters
mixed|string $value:
Return value
mixed|DateTime
Overrides StrategyInterface::hydrate
File
- vendor/
zendframework/ zend-hydrator/ src/ Strategy/ DateTimeFormatterStrategy.php, line 66
Class
Namespace
Zend\Hydrator\StrategyCode
public function hydrate($value) {
if ($value === '' || $value === null) {
return;
}
if ($this->timezone) {
$hydrated = DateTime::createFromFormat($this->format, $value, $this->timezone);
}
else {
$hydrated = DateTime::createFromFormat($this->format, $value);
}
return $hydrated ?: $value;
}