php error Message: Unsupported operand types

2

Hi, I'm doing a php operation with parentheses; and I get this error

error code:

  Fatal error: Unsupported operand types in 
   C:\xampp\htdocs\olPrueba2\application\controllers\Admin.php on line 705
   A PHP Error was encountered
    Severity: Error

    Message: Unsupported operand types

    Filename: controllers/Admin.php

    Line Number: 705

     Backtrace:

this is the line that says to have an error:

  $u=($yearC-$Yhire_date)*12;

How can I solve it, the variables I take from the database with a method, is it a date type for that?

code of the method:

 public function getyearHire($roster_salesforcename){

  $this->db->select('roster_hire_date');
  $this->db->where('roster_salesforcename', $roster_salesforcename);
  $this->db->group_by('YEAR(roster_hire_date)');
  $data = $this->db->get('ol_roster');

  $response = $data->result();

   return $response;
  }
    
asked by user80520 07.04.2018 в 00:56
source

1 answer

2

If the variables are dates you can not use the -. You have to use date_diff like this:

$u=date_diff($year,$Yhire_date);
    
answered by 07.04.2018 / 01:43
source