0

Inside my code i have an input field which i ask user a date. i want to compare it with present date and then give a variable a specific value I've simplified my code for you to understand it with example names . So far i made something like but it wont work ...

<?php    
if ((isset($_POST["input_Date"])) //Checking if the input is NOT empty
         && 
   ($_POST["input_Date"])>(date('Y-m-d')))) // Checking if the date is previous 
                                                         from current date 
        {$Variable="Correct"}//Give the variable i want a value

?>
DFd
  • 97
  • 8
  • `date('Y-m-d')` is a string. Strings won't be greater than anything. Unclear what `$_POST["input_Date"]` as well but likely not comparable. Likely https://www.php.net/manual/en/function.strtotime.php should be used.. or `time()` rather than `https://www.php.net/manual/en/function.strtotime.php` but will still need to convert the input I guess – user3783243 Jan 18 '22 at 21:11
  • Does this answer your question? [PHP date time greater than today](https://stackoverflow.com/questions/32642417/php-date-time-greater-than-today) – user3783243 Jan 19 '22 at 01:36

0 Answers0