Home  >  Article  >  Backend Development  >  How to use php microtime function

How to use php microtime function

青灯夜游
青灯夜游Original
2019-05-25 14:30:402701browse

The microtime() function is a built-in function in PHP that returns the current unix timestamp in microseconds. This function receives a single optional parameter get-as-float and returns the microsecond string by default.

How to use php microtime function

#How to use the php microtime() function?

php The microtime() function returns the microseconds of the current Unix timestamp. By default, it returns a microseconds string.

Syntax:

microtime(get_as_float)

Parameters:

● get_as_float: Optional. When set to TRUE , then it specifies that the function should return a float instead of a string representing the current time in seconds since the Unix epoch to the nearest microsecond. Defaults to FALSE, returning a string.

Note: The microtime() function is only available on operating systems that support the gettimeofday() system call.

Let’s take a look at how to use the php microtime() function through an example.

Example 1:

<?php
echo(microtime());
?>

Output: The specific output depends on the situation

0.56602000 1558765575

Example 2:

<?php
$str1 = microtime(true);
echo $str1;
?>

Output: The specific output depends on the situation

1558765604.4333

The above is the detailed content of How to use php microtime function. For more information, please follow other related articles on the PHP Chinese website!

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