PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<localtimemktime>
Last updated: Sat, 20 Oct 2007

microtime

(PHP 3, PHP 4, PHP 5)

microtime --  返回当前 UNIX 时间戳和微秒数

说明

string microtime ( void )

返回格式为“msec sec”的字符串,其中 sec 是当前的 Unix 时间戳,msec 是微秒部分。本函数仅在支持 gettimeofday() 系统调用的操作系统下可用。

字符串的两部分都是以秒为单位返回的。

例子 1. microtime() 例子

<?php
function getmicrotime(){
   list(
$usec, $sec) = explode(" ",microtime());
   return ((float)
$usec + (float)$sec);
   }

$time_start = getmicrotime();
  
for (
$i=0; $i < 1000; $i++){
  
//do nothing, 1000 times
  
}

$time_end = getmicrotime();
$time = $time_end - $time_start;

echo
"Did nothing in $time seconds";
?>

参见 time()




<localtimemktime>
 Last updated: Sat, 20 Oct 2007
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST