thewhat Posted December 22, 2007 Share Posted December 22, 2007 Hi all. I need some suggestions. I'm trying to set up this DB info where certain things are only available within x hours. I'm really stumped on how to go about doing this too. Can anyone help me or am I being too vague? Quote Link to comment https://forums.phpfreaks.com/topic/82788-solved-suggestions-for-mysqltime-use/ Share on other sites More sharing options...
phpSensei Posted December 22, 2007 Share Posted December 22, 2007 You know, there are alot of tutorials out there http://ca.php.net/manual/en/function.mktime.php http://www.devarticles.com/c/a/MySQL/Practical-Date-Time-examples-with-PHP-and-MySQL/1/ http://www.tizag.com/mysqlTutorial/mysql-time.php http://www.ilovejackdaniels.com/php/php-datediff-function/ http://ca.php.net/time Quote Link to comment https://forums.phpfreaks.com/topic/82788-solved-suggestions-for-mysqltime-use/#findComment-421039 Share on other sites More sharing options...
thewhat Posted December 22, 2007 Author Share Posted December 22, 2007 Well I know about all that. But I'm not sure how to apply it to get exactly what I need. I'll try to show you an example. info1 - 18 hours info2 - 12 hours info3 - 6 hours Each of those countdowns begins whenever the query is set and then is inserted into the other table of info at the end of the specified time. ??? Quote Link to comment https://forums.phpfreaks.com/topic/82788-solved-suggestions-for-mysqltime-use/#findComment-421066 Share on other sites More sharing options...
phpSensei Posted December 22, 2007 Share Posted December 22, 2007 Here is a code that DELETEs a data according to a time. $delete = mysql_query("DELETE FROM `table` WHERE `date` < '".(($now = time()) - $period)."'"); $period would be the time in seconds, just divide 18 hours into seconds. i am not sure if you want an INSERT STATEMENT, because then you would use if/else Quote Link to comment https://forums.phpfreaks.com/topic/82788-solved-suggestions-for-mysqltime-use/#findComment-421069 Share on other sites More sharing options...
thewhat Posted December 22, 2007 Author Share Posted December 22, 2007 Hrmm. I think I can work that out. Thank you very much! Quote Link to comment https://forums.phpfreaks.com/topic/82788-solved-suggestions-for-mysqltime-use/#findComment-421070 Share on other sites More sharing options...
phpSensei Posted December 22, 2007 Share Posted December 22, 2007 Hrmm. I think I can work that out. Thank you very much! No Problem. Topic Solved? Quote Link to comment https://forums.phpfreaks.com/topic/82788-solved-suggestions-for-mysqltime-use/#findComment-421072 Share on other sites More sharing options...
thewhat Posted December 22, 2007 Author Share Posted December 22, 2007 Indeed. *clicks it* Quote Link to comment https://forums.phpfreaks.com/topic/82788-solved-suggestions-for-mysqltime-use/#findComment-421077 Share on other sites More sharing options...
phpSensei Posted December 24, 2007 Share Posted December 24, 2007 You pm'ed me on a question and here is your answer/ <?php // Alright, lets say you want to insert data if it is certain date // // First you need the dates for this $period = array(); $period[then] = mktime(0, 0, 0, 12, 32, 2007); // This is only a certain date in 2007 $period[now] = time(); // The current Timestamp for now if($period[then]==$period[now]){ // If it is the date where you want things to change // Then you can insert a data mysql_query("INSERT INTO `table` ('field','field','field') VALUES ('$value','$value','$value')")or die(mysql_error()); } ?> Thats what i ment. Quote Link to comment https://forums.phpfreaks.com/topic/82788-solved-suggestions-for-mysqltime-use/#findComment-422560 Share on other sites More sharing options...
thewhat Posted December 25, 2007 Author Share Posted December 25, 2007 Ahhhhh! Alright, again thank you. Quote Link to comment https://forums.phpfreaks.com/topic/82788-solved-suggestions-for-mysqltime-use/#findComment-422718 Share on other sites More sharing options...
thewhat Posted December 25, 2007 Author Share Posted December 25, 2007 Ah yeah. But here's a problem. It wasn't going so I debugged and made $period[then] equal today(12/25/07). And when I echoed both variables, they weren't of the same value. What the hell? Quote Link to comment https://forums.phpfreaks.com/topic/82788-solved-suggestions-for-mysqltime-use/#findComment-422816 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.