Home >>PHP Date Time Functions >PHP getdate() Function
PHP getdate() function is used to get date and time information of the given current local date and time. It accepts one parameter that is the given timestamp. It returns an array with information of the given input timestamp.
Syntax:
getdate(timestamp);
Parameter | Description |
---|---|
timestamp | This is an optional parameter. This parameter defines the integer Unix timestamp. |
Here is an example of getdate() function in PHP:
<html> <body> <pre> <?php print_r(getdate()); ?> </pre> </body> </html>
Array ( [seconds] => 52 [minutes] => 32 [hours] => 8 [mday] => 1 [wday] => 6 [mon] => 2 [year] => 2020 [yday] => 31 [weekday] => Saturday [month] => February [0] => 1580545972 )
Example 2:
<html> <body> <?php $date=getdate(date("U")); echo "$date[mday] $date[month], $date[year] ($date[weekday])"; ?> </body> </html>