PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
afbase
Forum Contributor
Posts: 113 Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!
Post
by afbase » Fri Jun 15, 2007 9:48 pm
Is there a way in php to make the server count/wait/pause for a given time period? For instance
Code: Select all
while ($red = "wings for life"){
/* stuff done here */
count_time(5); //<---- that line makes php/server count 5 seconds before continuing with the script
}
Is there something like this????
afbase
Forum Contributor
Posts: 113 Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!
Post
by afbase » Fri Jun 15, 2007 10:28 pm
I made this script kinda on the fly. Does anyone see anything wrong with it? It runs fine for me but it just feels really shoddy:
Code: Select all
function time_diff($time_to_wait){
$now = time();
print date("m-d-Y G:i-s",$now);
for($i=0; $i <= $i+1;$i++){
$future = $now + $time_to_wait;
if (time() == $future) break;
$i=0;
}
print date("m-d-Y G:i-s",$future);
}
does anyone have a better idea that feels more kosher than this?
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Fri Jun 15, 2007 11:23 pm
afbase
Forum Contributor
Posts: 113 Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!
Post
by afbase » Fri Jun 15, 2007 11:33 pm
friggin sweet
Burrito++;
arukomp
Forum Contributor
Posts: 113 Joined: Sun Sep 24, 2006 4:22 am
Post
by arukomp » Sat Jun 16, 2007 5:14 am
Also you can use
usleep() to wait for microseconds