Contact: aviboots(AT)netvision.net.il
39,851 questions
51,772 answers
573 users
$starttime = time(); $seconds = 3; $endtime = $starttime + $seconds; while ($starttime < $endtime) { sleep(1); $starttime = time(); echo date("Y-m-d H:i:s", $starttime) . "\n"; } /* run: 2024-10-11 08:43:38 2024-10-11 08:43:39 2024-10-11 08:43:40 */
$startTime = time(); // Get the current time $duration = 3; // Duration in seconds while ((time() - $startTime) < $duration) { sleep(1); // Sleep for 1 second echo "Loop is running..." . "\n"; } /* run: Loop is running... Loop is running... Loop is running... */