我在控制器中使用DateTime:
$(document).ready(function() {
$(window).scroll(function() {
$('section[data-type="background"]').each(function(i,e) {
// scroll the background at var speed
// the yPos is a negative value because we're scrolling it UP!
var yPos = -($(window).scrollTop() / $(e).data('speed'));
// Put together our final background position
var coords = '50% '+ yPos + 'px';
// Move the background
$(e).css({ backgroundPosition: coords });
});
}); // end window scroll
});
但在视图中使用这些变量时:
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]);
}
我收到此错误:
htmlentities()期望参数1为字符串,给定对象
答案 0 :(得分:1)
您正在尝试显示对象而不是它的属性或其方法的结果:
{{ $nextday }}
您应该显示以下内容:
{{ $nextday->format('d') }}