for displaying dates i want to use two different formats, when a week has passed, the format should be: "June 11th 2023" and when the week limit hasn't been met, it should be something like: "4 days ago". that's the idea.
i have one method on my model to display one format:
public function getFormattedDate()
{
return $this->published_at->format('F jS Y');
}
on the blade i use the "x days ago" format on an if statement:
@if ($post->published_at=Carbon\Carbon::now()->subDays(6))
{{-- {{ $post->published_at->diffForHumans() }} --}}
a week has passed
@else
{{-- {{ $post->getFormattedDate() }} --}}
a week has not passed
@endif
I need to check if a week has passed because I want to show different formats but something is wrong, thanks.