php.js : microtime() function
microtime() function
The microtime() function returns the current time (either a string or a float) in seconds and microseconds
Version:
1103.1210
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 |
Example of php.js microtime() function:
In the following web document microtime() function returns current time in seconds and microseconds.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>php.js : microtime() function example</title>
<script type="text/javascript" src="../../phpjs/date/datetime.min.js"> </script>
</head>
<body>
<h1 style="color: green">php.js : microtime() function example</h1>
<h3>Current time(either a string or a float) </h3>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
document.write('microtime()'+'<br />');
document.write(microtime()+'<br />');
document.write('microtime(true)'+'<br />');
document.write(microtime(true));
//]]>
</script>
</body>
</html>
Output of the example:
microtime() 0.889 1309873693 microtime(true) 1309873693.889
Output vary time to time as current time changes.
View the example of php.js microtime() function in the browser
Previous: php.js : localtime() function
Next:
php.js : mktime() function
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics