Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php microseconds

Tags:

php

datetime

I'm using
echo date('H:i:s')." this step time\n";
in order to know how much time needs for each function in order to be executed.

How can I know the time with microseconds also?

like image 513
Duncan Benoit Avatar asked Dec 10 '22 21:12

Duncan Benoit


1 Answers

Just to add, there's PHP's microtime() function, which can be used like this:

$time_start = microtime(true);

//do stuff here

$time_end = microtime(true);
$time = $time_end - $time_start;

echo "It took $time seconds\n";
like image 99
karim79 Avatar answered Dec 13 '22 22:12

karim79