Backend Development 2 min read

PHP getdate() Function: Retrieve Date and Time Information

The PHP getdate() function returns an associative array with detailed date and time components based on a provided Unix timestamp or the current local time, explaining its parameters, return structure, and offering a practical code example with sample output.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
PHP getdate() Function: Retrieve Date and Time Information

The getdate() function in PHP returns an associative array containing date and time information derived from a given Unix timestamp, or the current local time if no timestamp is provided.

Parameters

timestamp (optional) – an integer Unix timestamp; if omitted, the function uses the current time returned by time() .

Return value

An associative array with keys such as seconds , minutes , hours , mday , wday , mon , year , etc., representing the corresponding components of the date and time.

Example

Sample output

Array
(
    [seconds] => 40
    [minutes] => 58
    [hours] => 21
    [mday] => 17
    [wday] => 2
    [mon] => 6
    [year] => 2003
    [yday] => 167
    [weekday] => Tuesday
    [month] => June
    [0] => 1055901520
)
backendPHPdate-timephp-functionsgetdate
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.