getdate
Description
The getdate of Date / Time for PHP get date/time information.
Syntax
getdate ( int|null $timestamp = null ) : array
Parameters
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 to 59 |
"minutes" | Numeric representation of minutes | 0 to 59 |
"hours" | Numeric representation of hours | 0 to 23 |
"mday" | Numeric representation of a day of the month | 1 to 31 |
"wday" | Numeric representation of a day of the week | 0 to 6 |
"mon" | Numeric representation of a month | 1 to 12 |
"year" | Numeric representation of a year | 0000 to 9999 |
"yday" | Numeric representation of a day of the year | 0 to 365 |
"weekday" | Textual representation of a day of the week | Sunday to Saturday |
"month" | Textual representation of a month | January to December |
0 | Seconds since the Unix Epoch | System Dependent (typically -2147483648 to 2147483647) |
Examples
1 · void
<? $return = getdate(); print_r($return);
Array ( [seconds] => 8 [minutes] => 58 [hours] => 21 [mday] => 7 [wday] => 6 [mon] => 12 [year] => 2024 [yday] => 341 [weekday] => Saturday [month] => December [0] => 1733608688 )
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