Reputation: 1672
I am using DateTime in controller as:
public function index()
{
$seats=seats::all();
$date = date('Y-M-D');
$tomorrow= new \DateTime('tomorrow');
$nextday= new \DateTime('tomorrow + 1day');
return view('bus.busview',['mytime'=>$date,'seats'=>$seats,'nextday'=>
$nextday,'tomorrow'=>$tomorrow]);
}
but while using these variables in view:
Your Name: <input type="name" name="name" id="name" ><br><BR>
Your Contact No. <input type="contact" name="contact" id="contact" ><br><BR>
Todays date:<mark>{{$mytime}}</mark><br><br>
tomorrows date:{{$tomorrow}}
Book for: <select>
<option name="select" value="{{$mytime}}">Today</option>
<option name="select" value="{{$tomorrow}}">Tomorrow</option>
<option name="select" value="{{$nextday}}">{{$nextday}}</option>
<option name="select" value="{{$nextday}}">{{$nextday}}</option>
</select>
i am getting this error:
htmlentities() expects parameter 1 to be string, object given
Upvotes: 1
Views: 240
Reputation: 163778
You're trying to display object instead of it's property or result of it's method:
{{ $nextday }}
You should display something like this:
{{ $nextday->format('d') }}
Upvotes: 1