zero_ZX Posted July 17, 2012 Share Posted July 17, 2012 Hi, I'm limiting a specific action to only be possible each 12 hour. To do that I use the current time: $time = strtotime(date("Y-m-d H:i:s")); and the last time the action was done is stored just like it (but from a db). Now I'm about to compare them, but I'm curious on how to make the last_vote variable 12 hours larger. I tried with 43200 which is 12 hours in seconds, but that appeared to be very incorrect. Any help is much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/265855-working-with-time/ Share on other sites More sharing options...
Barand Posted July 17, 2012 Share Posted July 17, 2012 if $last_vote is the datetime value from your database, if (time() > strtotime("+12 hours $last_vote") ) echo 'OK'; else echo 'Not yet'; Quote Link to comment https://forums.phpfreaks.com/topic/265855-working-with-time/#findComment-1362266 Share on other sites More sharing options...
zero_ZX Posted July 17, 2012 Author Share Posted July 17, 2012 Thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/265855-working-with-time/#findComment-1362282 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.