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
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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.