This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

aleXela
aleXela

Hey, i'm trying to use dateformat in model class, but getting an error:

"The separation symbol could not be found Trailing data" on line 582 of C:\wamp64\www\israplanet.com\vendor\nesbot\carbon\src\Carbon\Carbon.php

for protected $dateFormat = 'd-m-Y';

or this error: "Trailing data" on line 582 of C:\wamp64\www\israplanet.com\vendor\nesbot\carbon\src\Carbon\Carbon.php

for protected $dateFormat = 'Y';

what is the right format?

thanks

aleXela
aleXela

anyone? please

RedMarlin
RedMarlin

I dont know what you are trying to achieve but have you tried to simply change date format in fields.yaml:

date:
        type: datepicker
        format: d-m-Y
aleXela
aleXela

no, i'm trying to get date from a model and use it at the frontend nothing special used code from octobers docs, and getting an error

RedMarlin
RedMarlin

If you just want to display it on the front end then you dont need to do anything in the model. Just let Twig do the job, like this:

{{ my.date | date("d-m-Y") }}
aleXela
aleXela

i'm using handlebars, and it's not working there for some reason. i found a way how to make it there, but still it doesnt fix the problem. why i'm getting this error?

RedMarlin
RedMarlin

Thats hard to say but I would check the mysql column to see its formatting. Also I would debug the date variable and see what format it has on save and on read.

Sometimes this error is provoked by incompatibility in date formats ie you try to convert numeric date format into textual one (which is impossible) etc.

EDIT: One more idea. Did you added your date column to $dates in your model?

 protected $dates = [];

Last updated

1-7 of 7

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.