php 48hour countdown code

firebat

Beta member
Messages
1
what i need is a php countdown script but it only counts down to 48hours and then it resets back to 48 hours left till.....
eg.

48 hours left until server reset

2 hours later:

46 hours left until server reset

46 hours later:

0 hours left untill server reset

1min later

48 hours left until server reset.

get the idea?
i would like it to have min and seconds also.
thanks in advance
Firebat
 
I have one solution... it's a little messy,

Code:
<?php
$uep = date(U); //get Unix epoch time. (seconds since january 1st 1970)
$min = $uep/60; //turn the uep seconds into minutes
$hour = $min/60; //turn the minutes into hours
$hour = floor($hour); //round hour into an integer.
$day = $hour/24; // turn the hours into days
$biday = $day/2; //halve the days to make 48 hour blocks...
//check to make sure a whole number is found
if(($biday - (floor($biday))) == 0)
{
    print "48 Hours is up, time to start again";
}
if(($biday - (floor($biday))) != 0)
{
    for ($x=1;$x>0;$x++)
    {
        $hour = $hour+35;
        $day = $hour/24;
        $biday = $day/2;
        if(($biday - (floor($biday))) == 0)
        {
            $y = $x;
            $x=-10;
        }
    }
    print "$y hours to go";
}

?>
The problem with it is that it times out every two days (as requested) but it'll only time out at midnight, and only on certain days, you have no control over what days (as it's set by the Unix Epoch Time)...

the only way you can controll it is to either add or subtract seconds from the uep time variable

so after $uep = date(U);

have

$uep = $uep + $offset;

where offset is an amount of seconds it takes to shift the clock to time out at the time of day you want it to...
 
Back
Top Bottom