Call to a member function format() on a non-object Symfony datetime error

Call to a member function format() on a non-object Symfony datetime error

When you assign time for datetime in you Entity in Symfony project, you might get this problem. The fix is simple.
If you have your entity column setup as Date or datetime like

@ORMColumn(name="date_created", type="datetime", nullable=false)

The respective setDateCreated() method expects standard datetime object.
So,

$entity->setDateCreated(new DateTime());

will solve the problem. If you want to give different time other than today’s date, then you can populate DateTime object and provide that

Spring Data error: getOutputStream() has already been called for this response

No Persistence provider for EntityManager named Hibernate error

Java Tomcat error: can not access a member of class with modifiers

You asked to pull from the remote but did not specify the branch github error

Maven error Annotations are not supported in -source 1.3

eclipse j2ee error There are No resources that can be added or removed from the server

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*