Home > Article > Backend Development > Share PHP function microtime() calling skills_PHP tutorial
In order to add your own
definition and usage
PHP function microtime() returns the current Unix timestamp and microseconds number.
PHP function microtime() syntax
microtime(get_as_float)
PHP function microtime() parameters and description
get_as_float If the get_as_float parameter is given and its value is equivalent to TRUE, this function will return a floating point number.
Note
The PHP function microtime() is only available under operating systems that support the gettimeofday() system call.
If called without optional arguments, this function returns a string in the format "msec sec", where sec is the date since the Unix epoch (0:00:00 January 1, 1970 GMT) The number of seconds, msec is the microsecond part. Both parts of the string are returned in seconds.
PHP function microtime() example
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span> ?php </span></span></li><li><span>echo(microtime()); </span></li><li class="alt"><span class="tag">?></span><span> </span></span></li></ol>
Output:
0.25139300 1138197510
General usage of PHP function microtime() As follows:
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span> ?php </span></span></li><li><span>$</span><span class="attribute">mtime</span><span>=</span><span class="attribute-value">explode</span><span>(' ',microtime());</span></li><li><span>$</span><span class="attribute">startTime</span><span>=$mtime[1]+$mtime[0]; </span></li><li class="alt"><span>echo $startTime; </span></li><li><span class="tag">?></span><span> </span></span></li></ol>