PHP: getdate() function


The getdate() function accepts a timestamp and returns an associative array that contains the date and time information for a Unix timestamp.


(PHP 4 and above)




Name Description Required /
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


$tod = getdate(date("U"));

View the example in the browser

See also

PHP Function Reference

Previous: date
Next: gettimeofday

PHP: Tips of the Day

PHP: Anonymous recursive PHP functions

In order for it to work, you need to pass $factorial as a reference

$factorial = function( $n ) use ( &$factorial ) {
    if( $n == 1 ) return 1;
    return $factorial( $n - 1 ) * $n;
print $factorial( 5 );

Ref : https://bit.ly/38dj7jm