作者tonyofthu (晓白喵)
看板PHP
标题Re: [请益] 请问毫秒怎样写??
时间Tue Jun 17 22:25:08 2008
※ 引述《kung0226 (狮子男孩)》之铭言:
: 各位高手好
: 小弟在写一个码表计时器
: 目前毫秒写出来会有很大误差
: 好像是运算问题照成
: 是否有改善方式
: 我实验需要用到毫秒ㄟ
function counttime() //取得时间的函数
{
$time=explode(" ",microtime());
$msec=$time[0];
$sec=$time[1];
return $sec+$msec;
}
$first=counttime(); //起始时间
//这里放实验要跑的code
...
$last=counttime(); //结束时间
$result=$first-$last; //所花费的时间
$result*=1000; //result是以秒为单位, 乘上1000换成毫秒
小弟浅见, 参考看看吧~
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.128.194.150