Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.