pocobueno1388 Posted October 1, 2006 Share Posted October 1, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/22676-testing-against-a-datesolved/ Share on other sites More sharing options...
pocobueno1388 Posted October 1, 2006 Author Share Posted October 1, 2006 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/22676-testing-against-a-datesolved/#findComment-101977 Share on other sites More sharing options...
sasa Posted October 1, 2006 Share Posted October 1, 2006 try [code]$today = date ('Y-m-d', strtotime ("U"));[/code] Quote Link to comment https://forums.phpfreaks.com/topic/22676-testing-against-a-datesolved/#findComment-101980 Share on other sites More sharing options...
pocobueno1388 Posted October 1, 2006 Author Share Posted October 1, 2006 That gives me the same exact result ;) Quote Link to comment https://forums.phpfreaks.com/topic/22676-testing-against-a-datesolved/#findComment-101982 Share on other sites More sharing options...
sasa Posted October 1, 2006 Share Posted October 1, 2006 if ($row3['next_breed'] < $today){is it Oki think thet you must use > Quote Link to comment https://forums.phpfreaks.com/topic/22676-testing-against-a-datesolved/#findComment-101985 Share on other sites More sharing options...
Barand Posted October 1, 2006 Share Posted October 1, 2006 Shouldn't if ($row3['next_breed'] < $today){beif ($row3['next_breed'] > $today){ Quote Link to comment https://forums.phpfreaks.com/topic/22676-testing-against-a-datesolved/#findComment-101986 Share on other sites More sharing options...
pocobueno1388 Posted October 1, 2006 Author Share Posted October 1, 2006 Woah, talk about another brain fart. Thank you guys =) I thought I was switching that sign around to try to solve it...but I guess i was doing something wrong =/ Quote Link to comment https://forums.phpfreaks.com/topic/22676-testing-against-a-datesolved/#findComment-101991 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.