So I a published_at date time property in my posts.
Now id like to echo only the day for example 20 from the published_at property
and I need to echo the month separately in the short form , jan, feb etc.
Yes for sure this will create a problem.
You don't need a accessor, if working with carbon, its taken care for you. You accessor converts it to string and hence the error.
public function getPublishedAtFormattedAttribute($value)
{
return $this->published_at->format('d.m.Y H:i:s');
}
$post->published_at_formatted;
// or
$post->published_at->format('d.m.Y H:i:s');