Link to home
Start Free TrialLog in
Avatar of jblayney
jblayneyFlag for Canada

asked on

my strtotime is negative and wont compare

Hello,

i converted 2 dates into strtotime and am trying to compare which is more recent (greater than)

what happens is that it is dumping the results as a negative and wont compare greater than or equal to.


$dont_display = "false";
$morerecentn = 0;
do {


$inmates = $row_Recordset_inmates['last_inst_date'];
$morerecent = $row_Recordset_morerecent['last_inst_date'];


$inmatesn = strtotime($inmates);
$morerecentn = strtotime($morerecent);

echo $inmatesn;
echo $morerecentn;

if ($morerecentn > $inmatesn) {
$dont_display = "true";
}
} while ($row_Recordset_morerecent = mysql_fetch_assoc($Recordset_morerecent));
echo $dont_display;                   
                    ?>


what i see on the screen is

11168837200-11181016000true

the result is false, but for some reason displays as true, and again, why is it displaying as a negative
Avatar of glcummins
glcummins
Flag of United States of America image

Can you show the contents of $inmates and $morerecent so that we can determine if they are valid date strings? strtotime() will not work properly if the string that you give it is not in a valid format.

http://www.php.net/strtotime
ASKER CERTIFIED SOLUTION
Avatar of jblayney
jblayney
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of _GeG_
_GeG_

please post the result of
echo $inmates.':'.$morerecent;
should have refreshed the page before posting :-(
Closed, 125 points refunded.
Vee_Mod
Community Support Moderator