timeout php code example
Example 1: php time a script
$time_start = microtime(true);
for($i=0; $i<1000; $i++){
}
$time_end = microtime(true);
$execution_time = ($time_end - $time_start);
echo '<b>Total Execution Time:</b> '.($execution_time*1000).'Milliseconds';
Example 2: timeout php
<?php
set_time_limit(20);
while ($i<=10)
{
echo "i=$i ";
sleep(100);
$i++;
}
?>
Output:
i=0 i=1 i=2 i=3 i=4 i=5 i=6 i=7 i=8 i=9 i=10
Example 3: time php
<?php
$timestamp = time();
echo $timestamp . "<br>";
echo date("d/m/Y", $timestamp);
?>