How to use php microtime function

青灯夜游
Release: 2023-02-22 18:44:01
Original
2705 people have browsed it

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)
Copy after login

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());
?>
Copy after login

Output: The specific output depends on the situation

0.56602000 1558765575
Copy after login

Example 2:

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

Output: The specific output depends on the situation

1558765604.4333
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!