You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I've been using PHP-GDS to build a small e-commerce site and ran into a minor issue with the DateTime data type. It appears that after an upsert() the field defined as Datetime in the schema is not converted to the same representation as when the entity is fetched.
For my entity schema, I define a Datetime field like this:
addDatetime('date', true)
I then set my 'date' field to the PHP DateTime object like this:
$entity->date = new \DateTime('now', new \DateTimeZone('UTC'));
After I call upsert() and immediately do a var_export() on the entity, I can see the 'date' field is looking like this:
However, when I fetchById() or any fetch*() of the same object, var_export() gives me this:
'date' => '2017-06-12 10:29:13'
This behaviour is inconsistent. My current workaround it to do a fetchById() of my entity after upsert() however that seems a little inefficient. I could just check for the DateTime instance on the entity and set the field to just the date string, but that would make my entity handling code a little messy. Any suggestions?
The text was updated successfully, but these errors were encountered:
Hi, I've been using PHP-GDS to build a small e-commerce site and ran into a minor issue with the DateTime data type. It appears that after an upsert() the field defined as Datetime in the schema is not converted to the same representation as when the entity is fetched.
For my entity schema, I define a Datetime field like this:
I then set my 'date' field to the PHP DateTime object like this:
After I call upsert() and immediately do a var_export() on the entity, I can see the 'date' field is looking like this:
However, when I fetchById() or any fetch*() of the same object, var_export() gives me this:
This behaviour is inconsistent. My current workaround it to do a fetchById() of my entity after upsert() however that seems a little inefficient. I could just check for the DateTime instance on the entity and set the field to just the date string, but that would make my entity handling code a little messy. Any suggestions?
The text was updated successfully, but these errors were encountered: