# How to Start and Stop a Timer in PHP?

How to Start and Stop a Timer in PHP? We can utilize the microtime() capacity to begin and stop the clock in PHP. The microtime() work noticed the time in microseconds when it’s called. We will ascertain the time distinction between the stop time and the beginning clock to get the execution time. The right grammar to utilize this capacity is as per the following.

I really want some data with respect to beginning and halting a clock in PHP. I want to gauge the slipped by time from the beginning of my .exe program (I’m utilizing executive() work in my php script) until it finishes the execution and show the time it required right away.

You can begin and stop a clock in PHP utilizing the microtime() work in PHP. The microtime() work is an inbuilt capacity in PHP which is utilized to return the current Unix timestamp with microseconds.

In this article, you will become familiar with the employments of the microtime() work.

Syntax:

microtime( $get_as_float ) • Boundaries: The$get_as_float is sent as a boundary to the microtime() capacity, and it returns the string microsec as a matter of course.
• Bring Value back: By default, the microtime() work returns the time as a string, yet on the off chance that it is set to TRUE, the capacity returns the time as a string. So the default is FALSE.

Example 1:

 

Output

Displaying the micro time as a string :0.62248800 1620222618

Example 2:

 

Output

Displaying the micro time as a float :1620222618.9294

Note: The microtime()function is an inbuilt function in PHP which is used to return the current Unix timestamp with microseconds.

Example 3:

 

Output

The speed of code = 3.625461101532

Example 4:

 

Output

1620222618825