Jump to content

10 minute countdown


RockinPurdy

Recommended Posts

<?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

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

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

Thanks alecks.

 

But the countdown still isn't right :P

 

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.