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.
Copy link to clipboard
Copied
This was answered correctly in The Dreamwaever forum.
PHP query: How to determine if variable time is before or after today