PHP: getdate() function
PHP: Get date/time information
The getdate() function accepts a timestamp and returns an associative array that contains the date and time information for a Unix timestamp.
Version:
(PHP 4 and above)
Syntax:
getdate(timestamp)
Parameters:
| Name | Description | Required / Optional |
Type |
|---|---|---|---|
| timestamp | Unix timestamp. Default value : current local time. |
Required | String |
Return value:
An associative array. Details are as follows:
| Key | Description | Example returned values |
|---|---|---|
| seconds | Numeric value of seconds. | 0 to 59 |
| minutes | Numeric value of minutes. | 0 to 59 |
| hours | Numeric value of hours. | 0 to 23 |
| mday | Numeric value of the day of the month. | 1 to 31 |
| wday | Numeric value of the day of the week. | 0(for Sunday) through 6 (for Saturday) |
| mon | Numeric value of a month. | 1 through 12 |
| year | Four-digit numeric value of a year. | Examples: 1999 or 2003 |
| yday | Numeric value of the day of the year. | 0 through 365 |
| weekday | Full name of the day of the week. | Sunday through Saturday |
| month | Full name of a month. | 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 |
Value Type: Array
Example:
<?php
$tod = getdate(date("U"));
print_r($tod);
?>
View the example in the browser
See also
Previous: date
Next: gettimeofday
