The date to be checked is as follows :
$submission_date = 12-25-2014; //The date in mm-dd-yyyy format that is to be tested against today's date
Now I want to echo the error message since the date contained in a variable $submission_date
is a future date.
How should I do this efficiently and effectively using PHP?
Thanks in advance.
Many ways to do this (use DateTime::createFromFormat() to control exact format of input dates, for example) but perhaps the simplest that suits the example is:
Note that OP changed the question. If desired date to test against is not in $_POST array, just replace
strtotime($_POST['current_date'])
withtime()
to use current system time.To compare against current date, disregarding time of day, use: