 <p>The problem is that the "enddate" from your database isn't a number, it's a string.</p> <p>You should convert it to numbers:</p> <pre><code>$now = time(); $sql="SELECT enddate FROM campaigns WHERE id=".$data['camp']; $query = mysqli_query($db, $sql); while($result = mysqli_fetch_assoc($query)){ $db = strtotime($result); if($now &gt; $db) { // expired echo "&lt;script type='text/javascript'&gt;alert('This Workshop Has Expired'); &lt;/script&gt;"; exit; } else { // not expired echo "&lt;script type='text/javascript'&gt;alert('Thank You For Registering');&lt;/script&gt;"; exit; } } </code></pre>