setTimeout en setInterval bruikbare functies van Javascript samen met de sleep/usleep functie van php om tijdintervallen te zetten
setTimeout(function(){ alert("Hello"); }, 3000);
The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds.
1000 ms = 1 second.
The function is only executed once. If you need to repeat execution, use the setInterval() method.
Use the clearTimeout() method to prevent the function from running.
var myVar; function myFunction() { myVar = setInterval(alertFunc, 3000); } function alertFunc() { alert("Hello!"); }
En de php variant
<?php // current time echo date('h:i:s') . "\n"; // sleep for 10 seconds sleep(10); // wake up ! echo date('h:i:s') . "\n"; ?>