Difference between dates taken from SQL

Posted 1 year ago by kordix

I can easily get some difference between dates in the view f.e.

I can also use Carbon in controller and pass it to the view

$date = "2016-09-17 11:00:00"; $datecarbon = new Carbon($date);

return view('someview', compact('date'));

But I can't use it on sql records. I can't use DateTime object or Carbon inside @foreach blade directive and {{}} syntax.

F.e. I have a few hundred dates in the sql table and I want to add additional column with difference between dates.

It seems to be easy but I have to somehow combine controller logic and blade directives.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.