title: Cannot create an instance of DateTime from serialized data
body: <p>I have a problem with the date.
  Maybe I don't understand something in the process of serialization, but, when, I send a datetime to Api-Platform (Symfony) for example </p>
  
  <p><code>dateEvaluation: "2017-12-05T11:52:00.000Z"</code></p>
  
  <p>I obtain this message of error </p>
  
  <p><code>Cannot create an instance of DateTime from serialized data because its constructor requires parameter "time" to be present.</code></p>
  
  <p>This is my Entity </p>
  
  <pre><code>&lt;?php
  
  namespace App\Entity;
  
  use ApiPlatform\Core\Annotation\ApiResource;
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Serializer\Annotation\Groups;
  
  /**
   * @ORM\Entity(repositoryClass="App\Repository\EvaluationRepository")
   * @ORM\HasLifecycleCallbacks()
   * @ApiResource(attributes={
   *     "normalization_context"={
   *              "groups"={"Evaluation"}
   *              }
   *     })
   */
  class Evaluation
  {
      /**
       * @ORM\Id
       * @ORM\GeneratedValue
       * @ORM\Column(type="integer")
       * @Groups({"NotesEvaluations", "Evaluation"})
       */
      private $id;
  
      /**
       * @var \DateTime
       * @ORM\Column(type="datetime")
       * @Groups({"Evaluation"})
       */
      private $created;
  
      /**
       * @var \DateTime
       * @ORM\Column(type="datetime")
       * @Groups({"Evaluation"})
       */
      private $updated;
  
      /**
       * @var \DateTime
       * @ORM\Column(type="datetime")
       * @Groups({"Evaluation"})
       */
      private $dateEvaluation;
  
      /**
       * @var string
       *
       * @ORM\Column(type="text")
       * @Groups({"Evaluation"})
       */
      private $commentaire;
  
      /**
       * @var
       *
       * @ORM\ManyToOne(targetEntity="App\Entity\Personnel")
       * @Groups({"NotesEvaluations", "Evaluation"})
       */
      private $auteur;
  
      /**
       * @var
       *
       * @ORM\ManyToMany(targetEntity="App\Entity\Personnel")
       */
      private $autorises;
  
      /**
       * @var integer
       *
       * @ORM\Column(type="integer")
       */
      private $annee;
  
      /**
       * @var
       *
       * @ORM\ManyToOne(targetEntity="App\Entity\Module", inversedBy="evaluations")
       * @Groups({"Evaluation"})
       */
      private $module;
  
      /**
       * @var Boolean
       *
       * @ORM\Column(type="boolean")
       * @Groups({"NotesEvaluations"})
       */
      private $visible;
  
      /**
       * @var Boolean
       *
       * @ORM\Column(type="boolean")
       * @Groups({"NotesEvaluations"})
       */
      private $modifiable;
  
      /**
       * @var
       *
       * @ORM\ManyToOne(targetEntity="App\Entity\TypeGroupe")
       * @Groups({"Evaluation"})
       */
      private $typegroupe;
  
      /**
       * @var float
       *
       * @ORM\Column(type="decimal")
       * @Groups({"Evaluation"})
       */
      private $coefficient;
  
      /**
       * @return float
       */
      public function getCoefficient(): float
      {
          return $this-&gt;coefficient;
      }
  
      /**
       * @return mixed
       */
      public function getTypegroupe()
      {
          return $this-&gt;typegroupe;
      }
  
      /**
       * @param mixed $typegroupe
       */
      public function setTypegroupe($typegroupe): void
      {
          $this-&gt;typegroupe = $typegroupe;
      }
  
      /**
       * @return \DateTime
       */
      public function getDateEvaluation(): \DateTime
      {
          return $this-&gt;dateEvaluation;
      }
  
      /**
       * @param \DateTime $dateEvaluation
       */
      public function setDateEvaluation(\DateTime $dateEvaluation): void
      {
          $this-&gt;dateEvaluation = $dateEvaluation;
      }
  
      /**
       * @return string
       */
      public function getCommentaire(): string
      {
          return $this-&gt;commentaire;
      }
  
      /**
       * @param string $commentaire
       */
      public function setCommentaire(string $commentaire): void
      {
          $this-&gt;commentaire = $commentaire;
      }
  
      /**
       * @param float $coefficient
       */
      public function setCoefficient(float $coefficient): void
      {
          $this-&gt;coefficient = $coefficient;
      }
  
      /**
       * @return mixed
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * @return \DateTime
       */
      public function getCreated(): \DateTime
      {
          return $this-&gt;created;
      }
  
      /**
       * @param \DateTime $created
       */
      public function setCreated(\DateTime $created): void
      {
          $this-&gt;created = $created;
      }
  
      /**
       * @return \DateTime
       */
      public function getUpdated(): \DateTime
      {
          return $this-&gt;updated;
      }
  
      /**
       * @param \DateTime $updated
       */
      public function setUpdated(\DateTime $updated): void
      {
          $this-&gt;updated = $updated;
      }
  
      /**
       * @return mixed
       */
      public function getAuteur()
      {
          return $this-&gt;auteur;
      }
  
      /**
       * @param mixed $auteur
       */
      public function setAuteur($auteur): void
      {
          $this-&gt;auteur = $auteur;
      }
  
      /**
       * @return mixed
       */
      public function getAutorises()
      {
          return $this-&gt;autorises;
      }
  
      /**
       * @param mixed $autorises
       */
      public function setAutorises($autorises): void
      {
          $this-&gt;autorises = $autorises;
      }
  
      /**
       * @return int
       */
      public function getAnnee(): int
      {
          return $this-&gt;annee;
      }
  
      /**
       * @param int $annee
       */
      public function setAnnee(int $annee): void
      {
          $this-&gt;annee = $annee;
      }
  
      /**
       * @return mixed
       */
      public function getModule()
      {
          return $this-&gt;module;
      }
  
      /**
       * @param mixed $module
       */
      public function setModule($module): void
      {
          $this-&gt;module = $module;
      }
  
      /**
       * @return bool
       */
      public function isVisible(): bool
      {
          return $this-&gt;visible;
      }
  
      /**
       * @param bool $visible
       */
      public function setVisible(bool $visible): void
      {
          $this-&gt;visible = $visible;
      }
  
      /**
       * @return bool
       */
      public function isModifiable(): bool
      {
          return $this-&gt;modifiable;
      }
  
      /**
       * @param bool $modifiable
       */
      public function setModifiable(bool $modifiable): void
      {
          $this-&gt;modifiable = $modifiable;
      }
  
      /**
       * @ORM\PreUpdate
       */
      public function updateDate(): void
      {
          $this-&gt;setUpdated(new \Datetime());
      }
  
      public function __construct()
      {
          $this-&gt;setCreated(new \Datetime());
          $this-&gt;setUpdated(new \Datetime());
  
      }
  }
  </code></pre>
  
  <p>I don't understand why "time" is missing. Maybe it is for created or updated fields ? Anyway, created and updated fields return with ApiPlatform an object with timezone ...</p>
  
  <pre><code>created:
  {timezone: {name: "Europe/Paris",…}, offset: 561, timestamp: -62169984561}
  offset:561
  timestamp:-62169984561
  timezone:{name: "Europe/Paris",…}
  </code></pre>
  
  <p>Thanks for your help.
  David</p>