Javascript,Nodejs,MongodDB,WordPress,CSS,PHP

LightBlog

Wednesday, February 20, 2019

How to set default json date format in laravel


Use this function in model where we need to change default json date formate in human readable.
example: 1 day ago

        /**
        *  convert default date formate in human readable
        */
         protected function serializeDate(\DateTimeInterface $date)
       {
             return $date->diffForHumans();
        }

No comments:

Post a Comment