At 04:57 PM 1/3/2013, Marc Fromm wrote:
I am comparing to dates.

define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( date("m/d/Y", strtotime($jes)) < date("m/d/Y", strtotime(WSOFFBEGIN)) )
    {
        $error = " MUST begin after " . WSOFFBEGIN . "\n";
    }

I cannot figure out why the $error is being assigned inside the if statement, since the statement should be false. 01/03/2012 is not less than 09/16/2012.

You shouldn't be comparing the date strings, but the UNIX timestamp values:

define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( strtotime($jes) < strtotime(WSOFFBEGIN) )
{
$error = " MUST begin after " . WSOFFBEGIN . "\n";
}

Ken



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to