Home > Article > Backend Development > How to use php microtime function
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 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!