Home  >  Article  >  Backend Development  >  Share PHP function microtime() calling skills_PHP tutorial

Share PHP function microtime() calling skills_PHP tutorial

WBOY
WBOYOriginal
2016-07-15 13:33:57990browse

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>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446038.htmlTechArticleIn order to add your own definition and usage, the PHP function microtime() returns the current Unix timestamp and microseconds. PHP function microtime() syntax microtime(get_as_float) PHP function microtime() parameters and description...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn