// the current timestamp with microseconds.
// CuMicroTime.php
class CuMicroTime {
var $usec;
var $sec;
function CuMicroTime(/* CuMicroTime */ $MicroTime = null) {
if( $this->CheckClassType($MicroTime) )
{
$this->usec = $MicroTime->usec;
$this->sec = $MicroTime->sec;
}
else
{
list($this->usec, $this->sec) = explode(" ", microtime());
}
}
function Dec( /* CuMicroTime */ $MicroTime)
{
if( CheckClassType($MicroTime) )
return NULL;
$usec = (float)$this->usec - (float)$MicroTime->usec;
$sec = $this->sec - $MicroTime->sec;
$usec = substr($usec, 1);
return $sec.$usec;
}
function CheckClassType($MicroTime)
{
if( gettype($MicroTime) != 'object' || get_class($MicroTime) != "cumicrotime" )
return false;
else
return true;
}
}
2010年1月28日 星期四
CuMicroTime - the current timestamp with microseconds.
訂閱:
張貼留言 (Atom)
寫這個時後, 才知道PHP的時間精度真的很高!
回覆刪除