• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

PHP query: How to determine if variable time is before or after today

Participant ,
Oct 15, 2015 Oct 15, 2015

Copy link to clipboard

Copied

Hi,

I have this code which determines whether or not the return date of a book (format: d/m/Y) is before or after today.

<?php if($row['return_date'] >= date("d/m/Y")){ ?>

        <a href="loaning_remind.php?loan_id=<?php echo $row['id']; ?>" onClick="return confirm('The loaner will receive an email reminding them that their item loaned is due for return')">

        <div class="record_button">

            <img src="../images/icons/mail_icon_blue.png" width="100%" height="auto" title="Send Email Reminder">

            </div>

                Future

        </a>

        <?php } else { ?>

        <a href="loaning_remind_late.php?loan_id=<?php echo $row['id']; ?>" onClick="return confirm('The loaner will receive an email reminding them that the item loaned is late for return')">

        <div class="record_button">

            <img src="../images/icons/mail_icon_blue.png" width="100%" height="auto" title="Send Email Reminder">

            </div>

                Late

        </a>

<?php } ?>

At the moment it is not working, as the script checks the date and adds 2 months to it.

Eg:

Say today's date is: 15/10/2015

If the return date for the book is: 15/12/2015 (2 months from today), the script will display the NOT LATE icon.

If the return date for the book is 14/12/2015 (less than 2 months from today), the script will display the LATE icon.

I don't have any other script to do with time or date, so I have ruled out the possibility that it is getting messed up by other code.

Views

383

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2015 Oct 15, 2015

Copy link to clipboard

Copied

LATEST

This was answered correctly in The Dreamwaever forum.

PHP query: How to determine if variable time is before or after today

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines