vendredi 11 mars 2022

Calculating how many years are from a date

I'm a beginner in PHP, I started a project based on laravel framework and I have this issue. Also the version of PHP that I use is 8.1.3

So, I have a tabel. In this table I need to show a value if the person is hired for more than one year.

And I put in Model this code

public function hiringdate() {
         if(($this->now - $this->hiring_date) / (60 * 60 * 24) > 1) 
         {return 100;} 
       }

Also in Controller they are defined like this:

$newmember->hiring_Date = $req['hiring_date'];
$newmember->now = $now->strtotime("now");

What am I doing wrong here?

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire