somesh
somesh

Reputation: 548

Symfony datetime field format is not working

My entity field is:

/**
 * @ORM\Column(type="date", name="date", nullable=true)
 */
protected $date;

function getDate() {
    return $this->date;
}

function setDate($date) {
    $this->date = $date;
}

Here I try to update the data base using below command database is updated

php app/console doctrine:schema:update --force

But if I try to insert yyyy-mm-dd't'hh:mm:ss[2017-05-03T08:44:09+0000] this format I am getting this error:

Fatal error: Call to a member function format() on string in C:\xampp\htdocs\epitacrm\vendor\doctrine\dbal\lib\Doctrine\DBAL\Types\DateType.php on line 44

How to change respectively this time format I am taking datetime datatype it is also not working.

Upvotes: 2

Views: 1264

Answers (1)

Jakub Matczak
Jakub Matczak

Reputation: 15656

The value of $date property in your entity, should be a DateTime object, not a formatted string like you're trying to do now.

Upvotes: 1

Related Questions