RockinPurdy Posted January 25, 2008 Share Posted January 25, 2008 Hey, I would like to have a countdown on my website that counts down to the nearest 10 minute. Lol confusing. Eg. If it is 4:34:32 (hour,minutes,seconds) the countdown should display 5:28 Eg. If it is 10:39:58 the countdown should display 0:02 - Thanks Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/ Share on other sites More sharing options...
revraz Posted January 25, 2008 Share Posted January 25, 2008 If you want it to actually countdown dynamically, you need to use javascript. Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-448567 Share on other sites More sharing options...
RockinPurdy Posted January 25, 2008 Author Share Posted January 25, 2008 Really? This countdown doesn't use JS http://www.999tutorials.com/tutorial-show-time-left-with-php.html Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-448569 Share on other sites More sharing options...
revraz Posted January 25, 2008 Share Posted January 25, 2008 That's not a countdown per say, its just a static number. I thought you meant a dynamic counter. So if you already have a tutorial, why not use it? Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-448573 Share on other sites More sharing options...
RockinPurdy Posted January 25, 2008 Author Share Posted January 25, 2008 oh no.. I just need to display a countdown to the users. And the reason I don't use that tutorial is because I can't figure out how to do it for every 10 minutes. Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-448577 Share on other sites More sharing options...
cooldude832 Posted January 25, 2008 Share Posted January 25, 2008 <?php $hour = date("G"); $mins = floor(date("i")); $time_explode_hours = 15; $time_explode_mins = 50; $time_left_hours = $time_explode_hours-$hour; $time_left_mins = $time_explode_mints-$mins; if($time_left_mins < 0){ $time_left_hours--; $time_left_mins = $time_left_mins +60; } echo "The bomb will blow up in approximately ".$time_left_hours." hours and ".$time_left_mins." minutes!"; ?> So that will tell you how long before said bomb blows up Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-448580 Share on other sites More sharing options...
cooldude832 Posted January 25, 2008 Share Posted January 25, 2008 change the line $mins to <?php $mins = 10*floor(floatval(date("i")/10)); ?> That takes it from a number like 45 to 4.5 then floors it to 4.0 and then remultiples it by 10 to get 40. Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-448584 Share on other sites More sharing options...
RockinPurdy Posted January 25, 2008 Author Share Posted January 25, 2008 Okay, getting there. However the questions kinda confusing, I don't want to round it to the nearest 10 minutes. I want a countdown for every 10 minutes. So like say it's 12:32... I want the countdown to countdown to 12:40.... or if its' 4:35 I want it to countdown to 4:40... Understand? Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-448588 Share on other sites More sharing options...
cooldude832 Posted January 25, 2008 Share Posted January 25, 2008 that be going up not down <?php $mins = 10*ceil(floatval(date("i")/10)); $hour = date("G"); if($mins >60){ $mins = $mins-60; $hour++; } echo "The Time is : ".$hours.":".$mins; ?> Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-448592 Share on other sites More sharing options...
alecks Posted January 25, 2008 Share Posted January 25, 2008 if you made a script as a separate file, and in the header put a meta refresh, then had that script embedded in an iframe on the page you wanted it to show, you could make a fake dynamic javascript countdown. countdown.php <META HTTP-EQUIV="refresh" CONTENT="2"> <?php $mins = 10*ceil(floatval(date("i")/10)); $hour = date("G"); if($mins >60){ $mins = $mins-60; $hour++; } echo "The Time is : ".$hours.":".$mins; ?> index.html <iframe src="countdown.php" width="300" height="100" /> It'll refresh every 2 seconds... if you want to change it just set the content in the meta tag. Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-448596 Share on other sites More sharing options...
RockinPurdy Posted January 25, 2008 Author Share Posted January 25, 2008 Thanks alecks. But the countdown still isn't right It should always be less than 10 minutes... I'll try and reword this. If it is 12:34:21 (twelve thirty-four PM and twenty-one seconds) the countdown should display 5:39 (5 minutes and 39 seconds) Meaning there is 5 minutes and 39 seconds until 12:40... which is to the next 10 minute interval of the current time. Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-448598 Share on other sites More sharing options...
cooldude832 Posted January 25, 2008 Share Posted January 25, 2008 so you want a clock that is ten minuites slow? look at mktime and set the minuite parm to be the current mins- 10 Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-448600 Share on other sites More sharing options...
RockinPurdy Posted January 25, 2008 Author Share Posted January 25, 2008 Not necessarily... It should still be a countdown. Eg. 4 minutes and 12 seconds until the next update (It updates every 10 minutes) Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-448602 Share on other sites More sharing options...
RockinPurdy Posted January 25, 2008 Author Share Posted January 25, 2008 Anyone? Still not solved... Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-449128 Share on other sites More sharing options...
Zhadus Posted January 25, 2008 Share Posted January 25, 2008 Let me try and get this straight. You want a countdown TO the nearest 10 minute interval? So if it's 12:34, you want to show how many minutes and seconds to 12:40? If that's the case then you would do this: change the line $mins to <?php $mins = 10*floor(floatval(date("i")/10)); ?> And subtract the current minutes & seconds. Link to comment https://forums.phpfreaks.com/topic/87698-10-minute-countdown/#findComment-449213 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.