PHP getdate() function: Here, we will find out about the PHP getdate() function with its syntax, parameters, returns type, and example.
PHP getdate() function
getdate() function is utilized to get the neighborhood date/time (or it is additionally used to get the date/time dependent on the given timestamp.
Syntax:
getdate(timestamp); Parameter(s):
timestamp – It is a discretionary parameter which indicates the timestamp (which depends on an integer UNIX timestamp) – on the off chance that we don’t spend the timestamp the function restores the neighbourhood date/time.
Timestamps: Following are the timestamps,
- seconds – it is utilized to get the time in a moment or two
- minutes – it is utilized to get the time in minutes
- hours – it is utilized to get the time in hours
- mday – it is utilized to get the day of the month
- wday – it is utilized to get the day of the week
- mon – it is utilized to get the month
- year – it is utilized to get the year
- yday – it is utilized to get the day of the year
- weekday – it is utilized to get the name of the week
- month – it is utilized to get the name of the month
- 0 – it is utilized to get the seconds since Unix Epoch
Return value:
It restores a variety of the date/time data with the timestamp
Example: PHP code to show the example of getdate() function
<?php
//getting the complete date/time 
//i.e. local date/time
$result = getdate();
echo "getdate() result...\n";
print_r($result);
//extracting the indivisual values 
//based on the timestamps
echo "seconds:  $result[seconds]\n";
echo "minutes:  $result[minutes]\n";
echo "hours:    $result[hours]\n";
echo "mday:     $result[mday]\n";
echo "wday:     $result[wday]\n";
echo "mon:      $result[mon]\n";
echo "year:     $result[year]\n";
echo "yday:     $result[yday]\n";
echo "weekday:  $result[weekday]\n";
echo "month:    $result[month]\n";
echo "0:        $result[0]\n";
?>Output
getdate() result...
Array
(
    [seconds] => 28
    [minutes] => 56
    [hours] => 12
    [mday] => 13
    [wday] => 2
    [mon] => 8
    [year] => 2019
    [yday] => 224
    [weekday] => Tuesday
    [month] => August
    [0] => 1565700988
)
seconds:  28
minutes:  56
hours:    12
mday:     13
wday:     2
mon:      8
year:     2019
yday:     224
weekday:  Tuesday
month:    August
0:        1565700988Reference: PHP getdate() function
 
 