This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
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
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
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
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") }}
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?
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