I have to execute a piece of code in php and the code must be executed within 5 seconds.
if it is not executed within 5 seconds, a message should be 'echo'. Help me please.
I have to execute a piece of code in php and the code must be executed within 5 seconds.
if it is not executed within 5 seconds, a message should be 'echo'. Help me please.
get the start time before starting your code and end time after code in timestamp( which is in sec) and get difference after code end
$start_time = strtotime(date('d-M-Y g:i:s A'));
----
--- your piece of code
-----
$time_now = strtotime(date('d-M-Y g:i:s A'));
if($time_now-$start_time > 5)
{
echo "Some thing ";
}