Duncan Benoit
Duncan Benoit

Reputation: 3337

php microseconds

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?

Upvotes: 4

Views: 8693

Answers (3)

karim79
karim79

Reputation: 342655

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";

Upvotes: 9

Joel Cochran
Joel Cochran

Reputation: 7748

Use the 'u' marker in the format for milliseconds.

Upvotes: 1

knut
knut

Reputation: 4745

u  Microseconds (added in PHP 5.2.2)

Take a look at http://no.php.net/manual/en/function.date.php for more information.

Upvotes: 4

Related Questions