正如标题中所说,我想将日期与 Laravel 进行比较。这是我到目前为止所做的:if (isset($this->date_filed) && !empty($this->date_filed) && !empty($this->warranty_expiration)) { $warranty_expiration = Carbon::createFromFormat('m-d-Y', $this->warranty_expiration); $date_filed = Carbon::createFromFormat('m-d-Y', $this->date_filed); $this->with_warranty = $date_filed->lt($warranty_expiration) ? 'Y' : 'N';}如果提交日期小于保修到期打印 Y 否则 N在我的刀片文件中:<div class="form-group"> <label class="form-control-label"><b>Within Warranty:</b></label> <p>{{$model->with_warranty}}</p></div>但我收到此错误:找不到分隔符号\r\n尾随数据我做错了什么?
2 回答

人到中年有点甜
TA贡献1895条经验 获得超7个赞
你可以做
$warranty_expiration = date('m-d-Y', strtotime($this->warranty_expiration))
$date_filed = date('m-d-Y', strtotime($this->date_filed))
然后使用等于/更高或等于/更低进行适当的比较
您还可以使用“setAttribute”在保修是/否的情况下添加您想要的任何内容
- 2 回答
- 0 关注
- 666 浏览
添加回答
举报
0/150
提交
取消