NathanDTaylor Posted February 14, 2013 Share Posted February 14, 2013 (edited) So, basically, I have it set up so that banned users are in a table in the database called "bans". The lift date is formatted like such.. "02/14/2013 14:06AM" How can I make it so that if the date is passed, it removes the row from the table? Like how do I set up if($lift_date >= $c_date){ //remove } when using the time of day too? Edited February 14, 2013 by NathanDTaylor Quote Link to comment https://forums.phpfreaks.com/topic/274492-checking-if-date-passed/ Share on other sites More sharing options...
doddsey_65 Posted February 14, 2013 Share Posted February 14, 2013 if (strtotime($lift_date) < time()) { //remove ban } Quote Link to comment https://forums.phpfreaks.com/topic/274492-checking-if-date-passed/#findComment-1412479 Share on other sites More sharing options...
NathanDTaylor Posted February 14, 2013 Author Share Posted February 14, 2013 if (strtotime($lift_date) < time()) { //remove ban } And that will work with the current format I am using? Quote Link to comment https://forums.phpfreaks.com/topic/274492-checking-if-date-passed/#findComment-1412480 Share on other sites More sharing options...
doddsey_65 Posted February 14, 2013 Share Posted February 14, 2013 Sorry, You would need to remove the AM/PM from the date that you are using Quote Link to comment https://forums.phpfreaks.com/topic/274492-checking-if-date-passed/#findComment-1412481 Share on other sites More sharing options...
NathanDTaylor Posted February 14, 2013 Author Share Posted February 14, 2013 Sorry, You would need to remove the AM/PM from the date that you are using Oh, stupid me. I have a 24hour format and I put AM/PM on the end XD Quote Link to comment https://forums.phpfreaks.com/topic/274492-checking-if-date-passed/#findComment-1412482 Share on other sites More sharing options...
NathanDTaylor Posted February 14, 2013 Author Share Posted February 14, 2013 Sorry, You would need to remove the AM/PM from the date that you are using if I set the ban life date to 2/14/2013 8:45, it doesn't lift the bad. It says that 14:28 is earlier than 8:45? Quote Link to comment https://forums.phpfreaks.com/topic/274492-checking-if-date-passed/#findComment-1412485 Share on other sites More sharing options...
Barand Posted February 14, 2013 Share Posted February 14, 2013 The pains of not using correct datetime data types. You could use STR_TO_DATE() in your query to convert it to a DATETIME Quote Link to comment https://forums.phpfreaks.com/topic/274492-checking-if-date-passed/#findComment-1412488 Share on other sites More sharing options...
NathanDTaylor Posted February 14, 2013 Author Share Posted February 14, 2013 The pains of not using correct datetime data types. You could use STR_TO_DATE() in your query to convert it to a DATETIME In the MySQL Query? Because "STR_TO_DATE()" is not a valid PHP function Quote Link to comment https://forums.phpfreaks.com/topic/274492-checking-if-date-passed/#findComment-1412494 Share on other sites More sharing options...
Barand Posted February 14, 2013 Share Posted February 14, 2013 That's why I said "in your query" . EG SELECT * FROM mytable WHERE STR_TO_DATE(lift_date, '%m/%d/%Y %H:%i') < NOW() Quote Link to comment https://forums.phpfreaks.com/topic/274492-checking-if-date-passed/#findComment-1412502 Share on other sites More sharing options...
NathanDTaylor Posted February 14, 2013 Author Share Posted February 14, 2013 That's why I said "in your query" . EG SELECT * FROM mytable WHERE STR_TO_DATE(lift_date, '%m/%d/%Y %H:%i') < NOW() okay, thanks Quote Link to comment https://forums.phpfreaks.com/topic/274492-checking-if-date-passed/#findComment-1412520 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.