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.
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
<?php
$today = getdate();
print_r($today);
?>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
)Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
