Skip to content

Instantly share code, notes, and snippets.

@TomHAnderson
Created February 14, 2019 19:49
Show Gist options
  • Save TomHAnderson/f6789ba6dd6a54871eb0da365997cf23 to your computer and use it in GitHub Desktop.
Save TomHAnderson/f6789ba6dd6a54871eb0da365997cf23 to your computer and use it in GitHub Desktop.
DateTimeMicrosecondType
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null || $value instanceof DateTimeInterface) {
return $value;
}
$val = DateTime::createFromFormat('Y-m-d H:i:s.u', $value);
if (! $val) {
$val = date_create($value);
}
if (! $val) {
throw ConversionException::conversionFailedFormat(
$value,
$this->getName(),
'Y-m-d H:i:s.u'
);
}
return $val;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment