Jump to content

Testing against a date...*SOLVED*


pocobueno1388

Recommended Posts

Thanks to everyone who helped me with my last question, but after I fixed that I ran into another problem with the date, I am not very good at all with working with dates in PHP.

What my script does is when a user clicks a button which holds an ID of a dog, it will breed the dog and insert a date into the database which is 7 days from the date they just clicked the button.

What I want to do is next time they click the button to breed the dog is test whether the date in the database (which holds the date 7 days after they clicked last time) is either equal to todays date or if the current date has not reached the date in the database. If this is true it will display an error saying "You have already bred this dog in the last 7 days!".

I have tried doing this myself but it always displays the error message "You have already bred this dog in the last 7 days!"  whether it has been 7 days or not.
Here is my attempted code:

[code]
$today = date ('Y/m/d', strtotime ("U"));

if ($row3['next_breed'] < $today){
echo "<table class='main'><td class='main'>You must wait a week to breed this female again!<p>
She may be bred again on $row3[next_breed]</td></table>";
exit;
}
[/code]

$row3['next_breed'] is what holds the date +7 days from when they clicked the button last.

I am not sure if the default 'Date' in the database will effect anything. If they have never clicked the button the default date is obviously 0000-00-00, but I don't think that is the problem...it may be though.

Let me know what you guys think =) Thanks.

All help is greatly appreciated xP
Link to comment
https://forums.phpfreaks.com/topic/22676-testing-against-a-datesolved/
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.