2016-09-20 50 views
-1

我想通过比较两次来将日期增加1个数据。通过比较当前时间和给定时间增加日期1天

<?php 
    if(date("h:i a") > $query2['endtime']) 
    { 
     $date = new DateTime($date); 
     $date->modify('+1 day'); 
     echo $date->format('Y-m-d'); 
     echo '<input type="date" name="date" id="date" min="'.date("Y-m-d").'">'; 
    } 
    else 
    { 
     echo '<input type="date" name="date" id="date" min="'.date("Y-m-d").'">'; 
    } 

    ?> 

我想通过user.I给出的时间已经赚得了用户这样$query2['endtime']给出的时间来比较当前时间。但是,它显示我错误。

请检查我的代码和帮助。

+0

你已经错过了其他部分的左括号'否则{'< - 点击这里 – jitendrapurohit

+0

你能告诉我什么是这个代码@jitendrapurohit错误。 –

+0

你看到什么错误? – jitendrapurohit

回答

1

更改引号并添加'。'加入字符串

echo "<input type="date" name="date" id="date" min="echo date("Y-m-d"); ">"; 

到:

echo '<input type="date" name="date" id="date" min="' . date("Y-m-d") . '">'; 
+1

看看最后一个例子中的最后一个字符串,那里仍然有一些语法错误。 '日期(“Y-m-d”)。 “>';' - >'date(”Y-m-d“)。'”>';' – Qirel

+0

你说得对,谢谢:) – maciejolsz

+0

它会根据条件或不条件将日期递增1 @ maciejolsz,@ Qirel。 –