php CI 3 custom library => passing parameter to someclass

I am really new to Codeigniter, and just learning from scratch. I use CI3.

in native PHP I have a function like this
( to calculate the number of days between two dates) :

function dateDiff($date1, $date2){
$d1 = date_create($date1); $d2 = date_create($date2);
$diff = date_diff($d1,$d2);
$result =  $diff->format("%a");
return $result;
}

I have read the manual of CI3 & tried but no success.

this is my trial code

defined('BASEPATH') OR exit('No direct script access allowed');



class DateDiff { 
public $date1 = ''; public $date2 = '';
public function __construct($params)
{
    $d1 = date_create($this->date1); $d2 = date_create($this->date2);
    $diff = date_diff($d1,$d2);
    $result =  $diff->format("%a");
    return $result;
} }

then I call it in other controller, like this :

$NumberOfDays = $this->load->library('datediff', ['2025-01-01','2025-02-02']); echo $NumberOfDays;

Got error.

how to create such a function in CI3 custom library so I can call it in every controller