Search code examples
arrayssymfonyserializationdbal

Symfony2 | Error: Invalid serialization data for datetime object


I've been seeing this error in my logs for a couple of days ago when I did a composer update of my project.  

[2015-09-28 17:51:21] php.CRITICAL: Fatal Error: Invalid serialization data for DateTime object

Is it a bug Symfony2?


Solution

  • First of all, you should provide more information, if you want someone help you. But for now, I can suggest you to look at this issue posted on bugs.php.net.

    Here is the solution posted there:

    public function serialize() {
        return \serialize(array($this->myDateTimeObj->format('Y-m-d H:i:s')));
    }