corruptcity || skalman Posted February 5, 2010 Posted February 5, 2010 im making a new mod and in there im using timestamps but as ive never used timestamps before i was wondering if what ive done is correct and will work im just going to post the the code for the timestamp check rather than the whole function ifs its wrong would you peeps be able to point me in the right direction? what i want is if the money been in the bank longer than 6 hours the user is allowed to remove it if not they have to wait some more thanks skal. $q=$db->query("SELECT * FROM drugs_bank WHERE db_time = (unix_timestamp + 3600*60) WHERE userid = $userid"); if(mysql_num_rows($q) == 0) { echo"The time limit has expired yet please wait some more time"; } Quote
fbiss Posted February 5, 2010 Posted February 5, 2010 for 6 hours, you need to calculate 60 seconds x 60 mins x 6 hours = 21600 seconds So you want to find out if its been been longer then current time (unix_timestamp) minus 21600 seconds. $q=$db->query("SELECT * FROM drugs_bank WHERE db_time < unix_timestamp() - 21600 WHERE userid = $userid"); if(mysql_num_rows($q) == 0) { echo"The time limit has expired yet please wait some more time"; } Quote
corruptcity || skalman Posted February 5, 2010 Author Posted February 5, 2010 ah ok thanks fbiss i thought you worked it out the otherway round Quote
fbiss Posted February 5, 2010 Posted February 5, 2010 Actually i might be wrong "The time limit has expired yet please wait some more time" Do you mean "hasnt" if so, you need to invert the < to a > when db_time is set, is it set to current time or a future time stamp? Quote
corruptcity || skalman Posted February 5, 2010 Author Posted February 5, 2010 ok current time i think Quote
Magictallguy Posted February 5, 2010 Posted February 5, 2010 You're only displaying a message, you're not killing the page too ;) $q = $db->query("SELECT * FROM drugs_bank WHERE ((db_time = unix_timestamp - 21600) AND (userid = $userid))"); if(!$db->num_rows($q)) { echo "The time limit has expired yet please wait some more time"; $h->endpage(); exit; } Quote
Zero-Affect Posted February 5, 2010 Posted February 5, 2010 You're only displaying a message, you're not killing the page too ;) $q = $db->query("SELECT * FROM `drugs_bank` WHERE ((`db_time` = unix_timestamp - 21600) AND (`userid` = $userid))"); if( $db->num_rows($q) == 0 ) { echo ' The time limit has expired yet please wait some more time '; $h->endpage(); exit; } seems about right MTG. fbiss => C:\dos , C:\dos\run , run\dos\run still cracks me up when i read it lol Quote
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.