当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > localtime() 函数
The localtime() function returns an array that contains the time components of a Unix timestamp.
localtime()函数的作用是:以数组的形式返回本地时间。
localtime(timestamp,is_associative) |
Parameter参数 | Description描述 |
---|---|
timestamp | Optional. Specifies the date or time to be formatted. If no timestamp is specified, it uses the current local time. 可选参数。指定需要被定义的日期和时间。如果没有指定时间戳,那么它将默认使用本地时间。 |
is_associative | Optional. Specifies whether to return an associative or indexed array. If set to false the array returned is an indexed array. If set to true then the array returned is an associative array. The keys of the associative array are:
|
Example without and with associative arrays:
包含/不包含联合数组的情况:
<?php print_r(localtime()); echo("<br /><br />"); print_r(localtime(time(),true)); ?> |
The output of the code above could be:
上述代码将输出下面的结果:
Array ( [0] => 28 [1] => 35 [2] => 13 [3] => 25 [4] => 0 [5] => 106 [6] => 3 [7] => 24 [8] => 0 ) Array ( [tm_sec] => 28 [tm_min] => 35 [tm_hour] => 13 [tm_mday] => 25 [tm_mon] => 0 [tm_year] => 106 [tm_wday] => 3 [tm_yday] => 24 [tm_isdst] => 0 ) |