In laravel i am using this :
@php
$user_id = Session::get('agentid');
$res = DB::table('tbl_agent_details as tad')
->select('tad.licence_exp_date as date')
->where('tad.agent_id','=',$user_id)
->get();
$date_time=$res[0]->date;
$date = new DateTime($date_time);
$now = date('Y-m-d');
$dayss_left=$date->diff($now)->format("%d");
@endphp
//In $date_time i am getting :"2018-06-28"
//And In $now getting: "2018-02-25"
Its returning me erroe like:
DateTime::diff() expects parameter 1 to be DateTimeInterface, string given
What i am doing wrong here can anyone please tell i want days only
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire