On 11/11/2012 1:30 PM, Terry Ally (Gmail) wrote:
Hi all,
I am having a problem with comparing time. I am using the following:
$todaydate = date("D, M jS, Y g:i:s a");
$showenddate = date("D, M jS, Y g:i:s a",
strtotime($showsRecord['end_date']));
if ($todaydate > $showenddate):
echo "The date of the show has not yet arrived";
else:
echo "The show has ended";
endif;
The problem that I am encountering is that PHP is rendering the reverse of
the equation. For example:
If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*,
the message that I am getting is *the show has ended* which is wrong. A
test example is at http://www.lakesidesurrey.co.uk/test.php.
You can also me what I am doing wrong?
Thanks
Terry
Besides the minor fact that the code has syntax errors, the problem with
it is your if is backwrads. The facts are: today is less than end date,
so your if should show "The show has ended" since you are asking if
today IS GREATER than the end date.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php