Whedonite
asked on
Compare 2 dates from Form with PHP
Hi,
I do not have much experience coding and am trying to compare 2 dates as part of a form validation.
Basically, user inputs a "depart" date and a "return" date to a form. The dates need to be compared, and if the return date is earlier than the depart date it should throw an error "Return date must be later than depart date" and stop the form from being sent with wrong dates.
Any help is appreciated!!
Thanks!
I do not have much experience coding and am trying to compare 2 dates as part of a form validation.
Basically, user inputs a "depart" date and a "return" date to a form. The dates need to be compared, and if the return date is earlier than the depart date it should throw an error "Return date must be later than depart date" and stop the form from being sent with wrong dates.
Any help is appreciated!!
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I strongly suggest you also add a client validation since it is not worth going to the backend if the dates are wrong. That said, you always should test on the server too...
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
Back in a moment... ~Ray