strtotime()期望参数1是字符串,在codeigniter中给出的数组

I am assigning a token to user when he logs in, this token will be stored in database and will expire within 12 hours.

For this when the user logs in it will be shown in a view,

**my view is **

<a href=" <?php echo site_url('admin/checkval') ?> ">check valididty of token</a>

when he clicks on this,

My Controller

public function checkval(){

    $this->load->library('session');

    $goal = $this->session->userdata('user_id');
    $uid = $goal[0];
    $token = $goal[1];
    $this->load->model('loginmodel');

    $check_id = $this->loginmodel->token_valid($uid, $token);
    if($check_id){
      $data['query'] = $this->loginmodel->get_last_ten_entries();
       $this->load->view('admin/account', $data);
       print_r($data);
      echo "valid";
    }else {
        echo "invalid";
    }


 }

if his token is valid he will be shown list of users

model

public function token_valid($uid, $token){

  $responce = $this->db->query("SELECT expired_at FROM user_auth 
                                WHERE id = '$uid' AND token = '$token'");
  $date = strtotime($responce->result());
  echo "$date";
  $cdate = date("Y-m-d H:i:s");
  $cdate = strtotime($cdate);
  $interval = date_diff($date,$cdate);
  $hour = $interval->h;
  if(h<12){
    return TRUE;
  }else {
  return FALSE;  // code...
  }

}

database

In user_auth table i have,

id int(50),token varchar(500),expired_at datetime

but when i do this, the error occurs as follows,

strtotime() expects parameter 1 to be string, array given

date_diff() expects parameter 1 to be DateTimeInterface, boolean given

Trying to get property of non-object0

Use of undefined constant h - assumed 'h'

I think once the first error is resolved, others will go away. How do i do that? What am i doing wrong here? Thank you for your suggesions

Return a row() instead of result(), your model should be like this :

and date in date_diff() should be the DateTime objects from the date_create()

   public function token_valid($uid, $token)
   {
      $this->db->select('expired_at');
      $this->db->from('user_auth');
      $this->db->where('id',$uid);
      $this->db->where('token',$token);
      $query = $this->db->get();
      if ($query->num_rows() > 0)
      {
          $expired_date = $query->row()->expired_at;

          $expired_date = date_create($expired_date);
          $cdate = date_create('now');
          $interval = date_diff($expired_date,$cdate);
          $hour = $interval->h;
          if($hour < 12)
          {
            return TRUE;
          }else 
          {
            return FALSE;  
          }
      }   
   }

For more : http://php.net/manual/en/datetime.diff.php

$responce->result() return an object or an array

See doc : https://www.codeigniter.com/userguide3/database/results.html

If you are sure to have just one row :

$row = $responce->result()
$date = strtotime($row->expired_at);