The getdate() function returns an array that contains date and time information for a Unix timestamp.
The information returned is in the following form −
[seconds] - seconds
[minutes] - minutes
[hours] - hours
[mday] - day of the month
[wday] - day of the week
[mon] - month
[year] - year
[yday] - day of the year
[weekday] - name of the weekday
[month] - name of the month
[0] - seconds since Unix Epoch
Syntax
getdate(timestamp)
Parameters
timestamp − Integer Unix timestamp. Default is the current local time.
Return
The getdate() function returns date/time information of a timestamp or the current local date/time. The details about the information is shown above.
Example
The following is an example −
<?php print_r(getdate()); ?>
Output
The following is the output −
Array ( [seconds] => 8 [minutes] => 7 [hours] => 5 [mday] => 11 [wday] => 4 [mon] => 10 [year] => 2018 [yday] => 283 [weekday] => Thursday [month] => October [0] => 1539234428 )
Example
Let us see another example −
<?php $dt = getdate(date("U")); echo "$dt[weekday], $dt[month] $dt[mday], $dt[year]"; ?>
Output
The following is the output −
Thursday, October 11, 2018