English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Date & Time Function Manual
The getdate() function to obtain date/time information
The getdate() function to obtain information about a specific date/Time information. It accepts an optional parameter to specify the timestamp for which you need information. If no parameters are passed, this function returns information about the current local time.
Syntax
Parameter | Number |
---|---|
1 | Parameter and description timestamp/Timestamp of the date. This represents the timestamp for which you need information. |
The PHP getdate() function returns an array containing information about the given time/The following are the key units in the returned associative array:
Key name | Description | Return value example |
---|---|---|
"seconds" | The numeric representation of the second | 0 to 59 |
"minutes" | The numeric representation of the minute | 0 to 59 |
"hours" | The numeric representation of the hour | 0 to 23 |
"mday" | The numeric representation of the day of the month | 1 to 31 |
"wday" | The numeric representation of the day of the week | 0 (Sunday) to 6 (Saturday) |
"mon" | The numeric representation of the month | 1 to 12 |
"year" | 4 digit representation of the complete year | for example: 1999 or 2003 |
"yday" | The numeric representation of the day of the year | 0 to 365 |
"weekday" | The full text representation of the day of the week | Sunday to Saturday |
"month" | The full text representation of the month, such as January or March | January to December |
0 | seconds since the Unix epoch to the present day, and time() return values and for date() values are similar. | system-related, with a typical value of from -2147483648 to 2147483647. |
This function was initially introduced in PHP version4introduced and can be used in all higher versions.
The following examples demonstrategetdate()Usage of the function-
<?php $info = getdate(); print_r($info); ?>Test and see‹/›
Output result
Array ( [seconds] => 34 [minutes] => 52 [hours] => 12 [mday] => 8 [wday] => 5 [mon] => 5 [year] => 2020 [yday] => 128 [weekday] => Friday [month] => May [0] => 1588942354 )
Now, let's try to pass the timestamp to this function-
<?php $timestamp = time();-(23*12*30); $info = getdate($timestamp); print_r($info); ?>Test and see‹/›
Output result
Array ( [seconds] => 29 [minutes] => 49 [hours] => 10 [mday] => 8 [wday] => 5 [mon] => 5 [year] => 2020 [yday] => 128 [weekday] => Friday [month] => May [0] => 1588934969 )