我只想问,我有3个日期,今天的日期,date_of_needed和另一个提前2周的日期,我有这个代码:
$DateNeeded = $this->input->post('date_of_need');
$newDate = date("m-d-y",strtotime("+2 weeks"));
$d = $this->input->post('dateavail');
当我回应这3个日期时,我想出了这个:
Date Needed: 9/12/16
Date to be Reserved: 9/24/16
Date Today: 9/10/16
我希望有一个逻辑,如果产品少于2周,我就无法预订产品。我该怎么做? 这是我的逻辑
if($DateNeeded < $newDate){
echo "You need to reserve 2 weeks ahead!";
}
但它不起作用..谢谢你帮助我
答案 0 :(得分:0)
试试这个
$DateNeeded = strtotime($$DateNeeded);
$newDate = date("m-d-y",strtotime("+2 weeks"));
newDate_1 = strtotime($newDate);
if($DateNeeded < $newDate){
echo "You need to...."
}