sailorsmokey Posted May 2, 2009 Share Posted May 2, 2009 Hi everyone! I know my logic must be faulty somewhere here, because this if/else statement isn't returning the correct result. Could someone either correct me or at least give me enough direction to find my own mistake? I'm trying to take the current date, and check to see if it within the range of the date it becomes valid, and the expiration date. I thought this would be simple, and it probably is, but I'm missing something. Here's what I've got: $today=getdate(); if($today<$valid_date or $today>$exp_date) { echo "<p>Coupon has expired - discount not included in total.<br />"; } Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 2, 2009 Share Posted May 2, 2009 $today is an array, just so you know. var_dump($today); ^ that should display what's in the array. What values do $valid_date and $exp_date hold? Quote Link to comment Share on other sites More sharing options...
sailorsmokey Posted May 2, 2009 Author Share Posted May 2, 2009 Now I feel a little ridiculous. I used to be pretty handy with this PHP stuff, and I haven't touched it for a while, so I'm obviously quite a bit rusty. $valid_date is a value from MySQL table, stored as YYYY-MM-DD, and in this case it is 2009-05-01. $exp_date is the same, and in this case it is 2009-12-31. Any other comments that could help me out would be appreciated - meanwhile, I'll start reading up on date() and var_dump() a bit. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 2, 2009 Share Posted May 2, 2009 $today=date('Y-m-d', time()); if($today<$valid_date || $today>$exp_date) { echo "<p>Coupon has expired - discount not included in total.<br />"; } Try that. Quote Link to comment Share on other sites More sharing options...
sailorsmokey Posted May 2, 2009 Author Share Posted May 2, 2009 Thank you so much for not telling me to leave my head in the sand. I really appreciate it. This did work, and meanwhile, I will continue to study up and get my head back in the game. Quote Link to comment 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.