Quick Reach
The getdate function of PHP
The getdate() function returns the date/time information in the form of an associative array of a timestamp or the current local date/time.
Syntax of getdate in PHP
This is how you may use the getdate() function:
array getdate ([ int $timestamp = time() ] )
As such, the getdate() function returns a PHP associative array of current date-time, you can create an array and assign it the returned array. See example below.
Example of using PHP getdate()
The following example shows using the getdate function. The returned array is the displayed by using PHP foreach loop.
Experience this example online
1
2
3
4
5
6
7
8
9
|
<?php
$arrcurrdate = getdate();
print_r($arrcurrdate);
foreach ($arrcurrdate as $value)
{
echo $value . "</BR>";
}
?>
|
The output will be:
Array ( [seconds] => 58 [minutes] => 27 [hours] => 20 [mday] => 3 [wday] => 4 [mon] => 7 [year] => 2014 [yday] => 183 [weekday] => Thursday [month] => July [0] => 1404412078 ) 58
27
20
3
4
7
2014
183
Thursday
July
1404412078
Also read: PHP time | PHP mktime | timezone usage
Leave A Comment?