microtime()

1. 定义

该函数返回当前时间的Unix时间戳(当前时间离UNIX纪元 1970 年 1 月 1 日 00:00:00 的秒数)和微秒数。

2. 语法

microtime ([ bool $get_as_float = FALSE ] ) : mixed

3. 参数说明

参数 可选性 数据类型 描述
$get_as_float 可选 布尔型 返回结果是否为浮点数,默认为FALSE

4. 示例

<?php

// microtime()
// 返回当前时间的Unix时间戳(当前时间离UNIX纪元 1970 年 1 月 1 日 00:00:00 的秒数)和微秒数

$date = microtime();// 返回字符串,前面是当前时间的微秒,空格后为当前时间的时间戳
var_dump($date);
// 输出:string(21) "0.09250600 1566897763"

$date = microtime(true);// 返回浮点数,小数点前面是当前时间的时间戳,小数点后为当前时间的微秒
var_dump($date);
// 输出:float(1566897763.0927)