chrules Posted February 6, 2010 Share Posted February 6, 2010 Hey, I have been coding a bit on a site where you can login, submit your schedule in the form of posts. My problem is, that the users give a date to where the post is going to happen, and i wan't to check if the given date from the post is older than the current date. If so, then hide/do not show the post. Like this POST: Work the 22/02-10 at 19:00 - 20:00 <---- meaning the 22nd of February 2010 CURRENT DATE: 24/02-10 Then it should hide/remove the post so it isn't viewable. My php code is: <?php include "../../scripts/config.php"; include "../include/session.php"; global $max_items; $query = "SELECT calID, calDate, calName, calDesc," . "DATE_FORMAT(calDate, 'd/m-y') as date " . "FROM calTbl WHERE calUser='$username' ORDER BY calDate ASC"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { $calID = strip_tags( $row['calID']); $calStamp = $row['calStamp']; $calDate1 = strtotime( $row['calDate']); $calDate = strip_tags( $row['calDate']); $calName = strip_tags( $row['calName']); $calDesc = nl2br (strip_tags ($row['calDesc'], '<a><b><i><u>')); echo "<p><b>($calID) $calName the $calDate at $calDesc</b></p>"; echo "<p>----------------------------------------------------------------</p>";} ?> Any help would be appreciated, and if this post needs clarification please say so. In Advance, thx for any help. Quote Link to comment https://forums.phpfreaks.com/topic/191193-checking-if-date-given-in-post-is-older-than-current-date/ Share on other sites More sharing options...
sasa Posted February 7, 2010 Share Posted February 7, 2010 ... WHERE calUser='$username' AND calDate>NOW() ... Quote Link to comment https://forums.phpfreaks.com/topic/191193-checking-if-date-given-in-post-is-older-than-current-date/#findComment-1008263 Share on other sites More sharing options...
chrules Posted February 7, 2010 Author Share Posted February 7, 2010 Thanks for your reply. I've been trying to use curdate() but couldn't get that to work... Anyways, I implemented the function AND calDate>NOW() , but now it only displays the ones 3 days ahead of current time. Example: Todays date is the 7th using the NOW() statement, I can only see the ones from the 10th, and not the 9th or 8th. Now my question, i guess, is, how would one subtract time from the NOW() statement. so it'll be like "AND calDate>NOW()-(3 days)"? Quote Link to comment https://forums.phpfreaks.com/topic/191193-checking-if-date-given-in-post-is-older-than-current-date/#findComment-1008267 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.