(PHP 4, PHP 5)
getdate — 取得日期/时间信息
$timestamp
] )
返回一个根据 timestamp
得出的包含有日期信息的结合数组。如果没有给出时间戳则认为是当前本地时间。数组中的单元如下:
键名 | 说明 | 返回值例子 |
---|---|---|
"seconds" | 秒的数字表示 | 0 到 59 |
"minutes" | 分钟的数字表示 | 0 到 59 |
"hours" | 小时的数字表示 | 0 到 23 |
"mday" | 月份中第几天的数字表示 | 1 到 31 |
"wday" | 星期中第几天的数字表示 | 0(表示星期天)到 6(表示星期六) |
"mon" | 月份的数字表示 | 1 到 12 |
"year" | 4 位数字表示的完整年份 | 例如:1999 或 2003 |
"yday" | 一年中第几天的数字表示 | 0 到 365 |
"weekday" | 星期几的完整文本表示 | Sunday 到 Saturday |
"month" | 月份的完整文本表示 | January> 到 December |
0 | 自从 Unix 纪元开始至今的秒数,和 time() 的返回值以及用于 date() 的值类似。 | 系统相关,典型值为从 -2147483648 到 2147483647。 |
Example #1 getdate() 例子
<?php
$today = getdate();
print_r($today);
?>
以上例程的输出类似于:
Array ( [seconds] => 40 [minutes] => 58 [hours] => 21 [mday] => 17 [wday] => 2 [mon] => 6 [year] => 2003 [yday] => 167 [weekday] => Tuesday [month] => June [0] => 1055901520 )
参见 date(), time() 和 setlocale()。
Returns an associative array of information related to
the timestamp
. Elements from the returned
associative array are as follows:
Key | Description | Example returned values |
---|---|---|
"seconds" | Numeric representation of seconds | 0 to 59 |
"minutes" | Numeric representation of minutes | 0 to 59 |
"hours" | Numeric representation of hours | 0 to 23 |
"mday" | Numeric representation of the day of the month | 1 to 31 |
"wday" | Numeric representation of the day of the week | 0 (for Sunday) through 6 (for Saturday) |
"mon" | Numeric representation of a month | 1 through 12 |
"year" | A full numeric representation of a year, 4 digits | Examples: 1999 or 2003 |
"yday" | Numeric representation of the day of the year | 0 through 365 |
"weekday" | A full textual representation of the day of the week | Sunday through Saturday |
"month" | A full textual representation of a month, such as January or March | January through December |
0 | Seconds since the Unix Epoch, similar to the values returned by time() and used by date(). | System Dependent, typically -2147483648 through 2147483647. |
Example #2 getdate() example
<?php
$today = getdate();
print_r($today);
?>
以上例程的输出类似于:
Array ( [seconds] => 40 [minutes] => 58 [hours] => 21 [mday] => 17 [wday] => 2 [mon] => 6 [year] => 2003 [yday] => 167 [weekday] => Tuesday [month] => June [0] => 1055901520 )