1
我將使用保修日,月和年創建保修日期。一次輸入一條記錄時,此功能正常工作。但我必須爲同一表單中的不同項目輸入幾個保修天數。保修日期錯誤 - 拍攝日期
for($value = 0; $value < count(array_filter($part_name1)); $value++){
if(!empty($year1[$value])||!empty($month1[$value])||!empty($days1[$value])){
$warranty_date = $this->purchase_date;
if(!empty($days1[$value])){
$warranty = strtotime($this->warranty_date);
$warranty = strtotime("+".$this->days." day", $warranty);
$warranty = date('Y-m-d', $warranty);
$warranty_date = $warranty;
}
if(!empty($month1[$value])){
$warranty = strtotime($this->warranty_date);
$warranty = strtotime("+".$this->month." month", $warranty);
$warranty = date('Y-m-d', $warranty);
$warranty_date = $warranty;
}
if(!empty($this->year)){
$warranty = strtotime($this->warranty_date);
$warranty = strtotime("+".$this->year." year", $warranty);
$warranty = date('Y-m-d', $warranty);
$warranty_date = $warranty;
}
}
}
請幫我查找這段代碼的錯誤。
該功能基於購買日期。
當我輸入多條記錄時,第一個權證日期顯示爲1970-01-01
,第二個記錄保修日期正確,其餘顯示爲1970-01-01
。
發生了什麼事? –
它顯示第一個記錄1970-01-01,第二個記錄正確日期和第三個第四個等等。顯示1970-01-01 – Dula
你的數組是正確的嗎? –