I need to create a code in c# to check either the date picked is tomorrow onwards or has passed by today.
My idea is $checkDateInPass will get the current date minus with 1 day. Thus when a user enter a date either it was on THAT date or afterwards, $checkPass will fly a green flag to say that it passed the first validation. If it was otherwise, it will turned into an error.
Here's the code for date validation:
$checkDateInPass = date('d/m/Y',strtotime("-1 days"));
if($checkInDate > $checkDateInPass)
{
$checkPass += 1;
}
else
{
$message = "Please pick a proper date to check in.";
echo "<script type='text/javascript'>alert('$message');</script>";
}
Based on the above written code it work just fine IF I picked the check in date in the same month, but if I picked the check in date on the next month other than the current month, it doesn't work as expected.
Here's an example, lets say that $checkDateInPass is 27/12/2016:
A: I picked 29/12/2016 for first date, and 04/01/2017 for second date. It worked just fine.
B: I picked 04/01/2017 for first date, and 07/01/2017 for second date. It turns out to be wrong.
Is there any other IF statement to be considered for this statement?