w3resource

PHP: microtime() function

Description

The microtime() function creates current Unix timestamp with microseconds values.

Version:

(PHP 4 and above)

Syntax:

microtime(get_as_float) 

Parameter:

Name Description Required /
Optional
Type
get_as_float When it set to true then a float (in seconds) is returned instead of a string. Optional Boolean

Return value:

Unix timestamp

Value Type: Mixed*.

*Mixed : Mixed indicates multiple (but not necessarily all) types.

Example:

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

Output:

0.01583100 1295421766

Note: Since the current time is not static, therefore the output may vary.

View the example in the browser

See also

PHP Function Reference

Previous: localtime
Next: mktime



PHP: Tips of the Day

PHP: Anonymous recursive PHP functions

In order for it to work, you need to pass $factorial as a reference

$factorial = function( $n ) use ( &$factorial ) {
    if( $n == 1 ) return 1;
    return $factorial( $n - 1 ) * $n;
};
print $factorial( 5 );

Ref : https://bit.ly/38dj7jm