Go Back   Computer Forums > Web Design | Website Development > Web Programming
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 06-05-2005, 10:51 PM   #1
Beta Member
Join Date: Jun 2005
Posts: 1
Post php 48hour countdown code

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

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 is offline   Reply With Quote
Old 06-06-2005, 09:40 AM   #2
Site Team
root's Avatar
Join Date: Mar 2004
Posts: 7,872
Default Re: php 48hour countdown code

I have one solution... it's a little messy,

$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;
    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);


$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...
root is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 07:06 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0