I have a table in which I have two fields called created_at and updated_at in a table called processes, what I want to do is compare how many days there are between those two fields
I am using laravel 6
controller
$processes = Process::findOrFail(Crypt::decrypt(base64_decode($id)));
return view('clientes.show', compact('processes', 'histories', 'diligences', 'services', 'iva', 'dias'));
Query
SELECT TIMESTAMPDIFF(DAY,created_at, updated_at) AS days FROM processes
WHERE id = 1
I already could, I put this in my model and call it in the blade view
blade
You can use the method
diffInDays
that Carbon already provides in Laravel.You should:
Example
EDITION
I add an example of using the method
diffInDays()
from TinkerReference