Mutley Posted August 26, 2008 Share Posted August 26, 2008 I have a variable that contains a 12 figure unix time ($oldtime). This updates to the current time every 2 hours. What I wish to do with this, is display the time left... before it resets again, so it's counting down from 2 hours to 0, in which it then gets reset and it starts counting down all over again. How would I do this? Kind Regards, Nick. Quote Link to comment https://forums.phpfreaks.com/topic/121460-time-left-with-unix-time/ Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 $timeleft = ($oldtime + (60 * 60 * 2)) - time(); Quote Link to comment https://forums.phpfreaks.com/topic/121460-time-left-with-unix-time/#findComment-626325 Share on other sites More sharing options...
zq29 Posted August 26, 2008 Share Posted August 26, 2008 <?php $diff = time() - $oldtime; ?> Quote Link to comment https://forums.phpfreaks.com/topic/121460-time-left-with-unix-time/#findComment-626328 Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 You need to add 2 hours to the old time in order to actually see when it'll update. Quote Link to comment https://forums.phpfreaks.com/topic/121460-time-left-with-unix-time/#findComment-626329 Share on other sites More sharing options...
Mutley Posted August 26, 2008 Author Share Posted August 26, 2008 So: <?php $diff = time() - ($oldtime + 7200); ?> Thanks for the speedy replies! I shall test it out. Quote Link to comment https://forums.phpfreaks.com/topic/121460-time-left-with-unix-time/#findComment-626358 Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 No, use mine. You have the subtraction in the wrong order. Quote Link to comment https://forums.phpfreaks.com/topic/121460-time-left-with-unix-time/#findComment-626364 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.