Link to home
Start Free TrialLog in
Avatar of pc-buddy
pc-buddy

asked on

Laravel format Error

Hi,

my code worked fine but has suddenly died

{{ str_limit($child['date_of_birth']->format('d-m-Y'), $limit = 10, $end = '') }}

Open in new window


I get this error

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

Please help thanks
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

This is a debugging activity which may take more than a couple of steps.

To get started, use something like Laravel dd() to print out the contents of $child.  The code expects to find an object in the $child array at the index named 'date_of_birth'.  If that's not an object (of the type that would have a format() method, make your way "upstream" in the code to the place where the $child array is populated.
Avatar of pc-buddy
pc-buddy

ASKER

ya it works fine without the format option added, the date if just displayed in the wrong order so i'm trying to format it correctly.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the help, got me to the fix