HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

getdate

Description

The getdate of Date / Time for PHP gets date/time information.

Syntax

getdate(
    ?int $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:

KeyDescriptionExample
"seconds"Numeric representation of seconds0 - 59
"minutes"Numeric representation of minutes0 - 59
"hours"Numeric representation of hours0 - 23
"mday"Numeric representation of a day of the month1 - 31
"wday"Numeric representation of a day of the week0 - 6 (Sunday - Saturday)
"mon"Numeric representation of a month1 - 12
"year"Numeric representation of a year0000 - 9999
"yday"Numeric representation of a day of the year0 - 365
"weekday"Textual representation of a day of the weekSunday - Saturday
"month"Textual representation of a monthJanuary - December
0Seconds since the Unix EpochSystem Dependent (typically -2147483648 - 2147483647)

Examples

1 · void

<?

$return = getdate();

print_r($return);
Array
(
    [seconds] => 44
    [minutes] => 29
    [hours] => 4
    [mday] => 12
    [wday] => 6
    [mon] => 9
    [year] => 2026
    [yday] => 254
    [weekday] => Saturday
    [month] => September
    [0] => 1789187384
)

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
)