PHP | getdate() Function
The getdate() function is an inbuilt function in PHP which is used to get date/time information of the current local date/time.
Syntax:
getdate($timestamp)
Parameters: The getdate() function accepts one parameter and it is described below:
- $timestamp: It is an optional parameter which specifies an integer unix timestamp. Default is the current local time (time()).
Return Value:
The function returns an array with information of the timestamp.
- [seconds] – seconds
- [minutes] – minutes
- [hours] – hours
- [mday] – day of the month
- [wday] – day of the week
- [mon] – month
- [year] – year
- [yday] – day of the year
- [weekday] – name of the weekday
- [month] – name of the month
- [0] – seconds since Unix Epoch
Below programs illustrate the getdate() function in PHP:
Program 1:
<?php // PHP program to illustrate // getdate() function print_r(getdate()); ?> |
Array
(
[seconds] => 40
[minutes] => 25
[hours] => 6
[mday] => 3
[wday] => 2
[mon] => 7
[year] => 2018
[yday] => 183
[weekday] => Tuesday
[month] => July
[0] => 1530599140
)
Program 2:
<?php // Unix timestamp for date // 27-june-2018 10:10:10 // is 1530094210 $y = 1530094210; $today = getdate($y); print_r($today); ?> |
Array
(
[seconds] => 10
[minutes] => 10
[hours] => 10
[mday] => 27
[wday] => 3
[mon] => 6
[year] => 2018
[yday] => 177
[weekday] => Wednesday
[month] => June
[0] => 1530094210
)
Reference: http://php.net/manual/en/function.getdate.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name inside a function in PHP ?
- How to get the function name from within that function using JavaScript ?
- PHP | Ds\Map map() Function
- PHP | Ds\Map last() Function
- p5.js | box() Function
- PHP | min( ) Function
- PHP | max( ) Function
- D3.js | d3.map.set() Function
- CSS | rgb() Function
- p5.js | str() function
- D3.js | d3.rgb() Function
- p5.js | value() Function
- p5.js | int() function
- p5.js | hex() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



