Khandaker Toihidul Islam
Front-end Developer
React Js | Javascript | HTML | CSS | Bootstrap | Wordpress | PHP | Mysql

Ctreated_at and updated_at in symfony

We need to modify the entity as following

/**
  * @ORM\HasLifecycleCallbacks
 */
class Distribution

-----------------------------------

   /**
     * Gets triggered only on insert
     * @ORM\PrePersist
     */
    public function onPrePersist()
    {
        $this->created_at = new \DateTime("now");
    }

   /**
     * Gets triggered only on update
     * @ORM\PreUpdate
     */
    public function onPreUpdate()
    {
        $this->updated_at = new \DateTime("now");
    }

You may also like...

Leave a Reply