php - I need to get the interval between two dates, one is from system date, and one is from the database

one text

Solution:

$tenggat = DB::table('tower')->select('tower.tenggat_izin')->get();

return the collection of objects, and you need just first one.

$rows = DB::table('tower')->select('tower.tenggat_izin')->get();
$tenggat = $rows[0]; 
$diff = Carbon::now()->diffInDays(Carbon::parse($tenggat->tenggat_izin));
$diff2 = Carbon::parse($tenggat->tenggat_izin)->diffInDays(Carbon::now();

I am not sure about field naming, but this code returns the diff in days between the current date and tenggat_izin field from table tower

It's not a good way, as said above use eloquent, and it will be much easier

Source