正如標(biāo)題中所說,我想將日期與 Laravel 進(jìn)行比較。這是我到目前為止所做的: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>但我收到此錯(cuò)誤:找不到分隔符號(hào)\r\n尾隨數(shù)據(jù)我做錯(cuò)了什么?
2 回答

人到中年有點(diǎn)甜
TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超7個(gè)贊
你可以做
$warranty_expiration = date('m-d-Y', strtotime($this->warranty_expiration))
$date_filed = date('m-d-Y', strtotime($this->date_filed))
然后使用等于/更高或等于/更低進(jìn)行適當(dāng)?shù)谋容^
您還可以使用“setAttribute”在保修是/否的情況下添加您想要的任何內(nèi)容
- 2 回答
- 0 關(guān)注
- 695 瀏覽
添加回答
舉報(bào)
0/150
提交
取消