i can not understand how can i persist datetime to database. I have string
(string) $oXml->currentTime
actually it’s not a string but we convert it, so how can i add it to entity without error
Fatal error: Call to a member function format() on a non-object in...
current code
$currentTime = \DateTime::createFromFormat('Y-m-d H:m:s', (string) $oXml->currentTime);
$cachedUntil = \DateTime::createFromFormat('Y-m-d H:m:s', (string) $oXml->cachedUntil);
$oApiKeyInfo
->setCurrentTime($currentTime)
->setCachedUntil($cachedUntil)
not working 🙁
You need to pass the a DateTime object. Create it with a new statement, you can specify the time to use with the first constructor parameter.
If you need to specify a Timezone you can use the DateTimeZone class and pass it as the second parameter to the DateTime constructor.