/** 擷取目前時間戳,精确到毫秒 */
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
/** 格式化時間戳,精确到毫秒,x代表毫秒 */
function microtime_format($tag, $time)
list($usec, $sec) = explode(".", $time);
$date = date($tag,$usec);
return str_replace('x', $sec, $date);
使用方法:
1. 擷取目前時間戳(精确到毫秒):microtime_float()
2. 時間戳轉換時間:microtime_format('Y年m月d日 H時i分s秒 x毫秒', 1270626578.66000000)