Open In App
Related Articles

PHP | microtime() Function

Improve Article
Save Article
Like Article

The microtime() function is an inbuilt function in PHP which is used to return the current Unix timestamp with microseconds. The $get_as_float is sent as a parameter to the microtime() function and it returns the string microsec sec by default.


microtime( $get_as_float )

Parameters: This function accepts single parameter $get_as_float which is optional. If $get_as_float is set to TRUE then it specify that the function should return a float, instead of a string.

Return Value: It returns the string microsec sec by default, where sec is the number of seconds since the Unix Epoch (0:00:00 January 1, 1970, GMT), and microsec is the microseconds part. If the $get_as_float parameter is set to TRUE, it returns a float representing the current time in seconds since the Unix epoch accurate to the nearest microsecond.

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

Below programs illustrate the microtime() function in PHP:

Program 1:

// Displaying the micro time as a string
echo ("The micro time is :");


The micro time is :0.51423700 1535452933

Program 2:

// Displaying the micro time as a float type
echo ("The micro time is :");


The micro time is :1535452935.2589

Related Articles:


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 28 Aug, 2018
Like Article
Save Article
Similar Reads
Complete Tutorials