getdate
Description
The getdate of Date / Time for PHP gets date/time information.
Syntax
getdate(
?int $timestamp = null
): arrayParameters
timestamp
The optional timestamp parameter is an integer Unix timestamp that defaults to the current local time if a timestamp is not given. In other words, it defaults to the value of time().
Return
Returns an associative array of information related to the timestamp. Elements from the returned associative array are as follows:
| Key | Description | Example |
|---|---|---|
| "seconds" | Numeric representation of seconds | 0 - 59 |
| "minutes" | Numeric representation of minutes | 0 - 59 |
| "hours" | Numeric representation of hours | 0 - 23 |
| "mday" | Numeric representation of a day of the month | 1 - 31 |
| "wday" | Numeric representation of a day of the week | 0 - 6 (Sunday - Saturday) |
| "mon" | Numeric representation of a month | 1 - 12 |
| "year" | Numeric representation of a year | 0000 - 9999 |
| "yday" | Numeric representation of a day of the year | 0 - 365 |
| "weekday" | Textual representation of a day of the week | Sunday - Saturday |
| "month" | Textual representation of a month | January - December |
| 0 | Seconds since the Unix Epoch | System Dependent (typically -2147483648 - 2147483647) |
Examples
1 · void
<? $return = getdate(); print_r($return);
Array
(
[seconds] => 44
[minutes] => 29
[hours] => 4
[mday] => 12
[wday] => 6
[mon] => 9
[year] => 2026
[yday] => 254
[weekday] => Saturday
[month] => September
[0] => 1789187384
)
2 · timestamp
<? $hour = 4; $minute = 5; $second = 6; $month = 2; $day = 3; $year = 2001; $timestamp = mktime($hour, $minute, $second, $month, $day, $year); $return = getdate($timestamp); print_r($return);
Array
(
[seconds] => 6
[minutes] => 5
[hours] => 4
[mday] => 3
[wday] => 6
[mon] => 2
[year] => 2001
[yday] => 33
[weekday] => Saturday
[month] => February
[0] => 981173106
)
Links
Date / Time
- checkdate
- date
- date_add
- date_create
- date_create_from_format
- date_create_immutable
- date_create_immutable_from_format
- date_date_set
- date_default_timezone_get
- date_default_timezone_set
- date_diff
- date_format
- date_get_last_errors
- date_interval_create_from_date_string
- date_interval_format
- date_isodate_set
- date_modify
- date_offset_get
- date_parse
- date_parse_from_format
- date_sub
- date_sun_info
- date_sunrise
- date_sunset
- date_time_set
- date_timestamp_get
- date_timestamp_set
- date_timezone_get
- date_timezone_set
- gettimeofday
- gmdate
- gmmktime
- gmstrftime
- idate
- localtime
- microtime
- mktime
- strftime
- strptime
- strtotime
- time
- timezone_abbreviations_list
- timezone_identifiers_list
- timezone_location_get
- timezone_name_from_abbr
- timezone_name_get
- timezone_offset_get
- timezone_open
- timezone_transitions_get
- timezone_version_get