Jump to content

Conditional Checking Less Than Value


tec-4

Recommended Posts

Hello all,

 

Have a conditional statement that I would only like to appear only if one variable is less than another one.

 

For example, I have example code as follows:

 

<?php
foreach($numbers as $number) 
        {
?>
      <div class="number">
         <div class="number_highlight"> 
              <?php 
                    $show_new_date = round((time() - strtotime($number->BeginningDate)) / (60 * 60 * 24));
                    $testing_low_date = 14;
                        if ($show_new_date <= $testing_low_date) 
                          { 
                              echo '<p>hello</p>'; 
                           }
     }
?>

 

I cannot seem to echo the statement correctly with the above calculations and conditional statement.

 

The $show_new_date  is a date from a database, from when something was created and $testing_low_date is the number of days I'd like to test to see if the date from the database is below

 

Anyone see where in the above code I may be going wrong, or overlooking?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/239693-conditional-checking-less-than-value/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.