简体   繁体   中英

Increment the date by 1 day by comparing the current time and given time

I want to increment the date by 1 day by comparing two times.

This is my code:

   <?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").'">';
    }

    ?>

I want to compare the current time by the time given by the user. I have fetched the time given by the user like this $query2['endtime'] . But, it is showing me the error.

Please check my code and help.

Any help is much appreciated.

change quotes and add '.' to join strings

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

to:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM