PHP | getdate() Function Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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 // PHP program to illustrate // getdate() function print_r(getdate()); ?> Output: 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 <?php // Unix timestamp for date // 27-june-2018 10:10:10 // is 1530094210 $y = 1530094210; $today = getdate($y); print_r($today); ?> Output: Array ( [seconds] => 10 [minutes] => 10 [hours] => 10 [mday] => 27 [wday] => 3 [mon] => 6 [year] => 2018 [yday] => 177 [weekday] => Wednesday [month] => June [0] => 1530094210 ) Reference: https://www.php.net/manual/en/function.getdate.php Create Quiz Comment R R_Raj Follow 0 Improve R R_Raj Follow 0 Improve Article Tags : Web Technologies PHP PHP-date-time PHP-function Explore PHP Tutorial 8 min read BasicsPHP Syntax 4 min read PHP Variables 5 min read PHP | Functions 8 min read PHP Loops 4 min read ArrayPHP Arrays 5 min read PHP Associative Arrays 4 min read Multidimensional arrays in PHP 5 min read Sorting Arrays in PHP 4 min read OOPs & InterfacesPHP Classes 2 min read PHP | Constructors and Destructors 5 min read PHP Access Modifiers 4 min read Multiple Inheritance in PHP 4 min read MySQL DatabasePHP | MySQL Database Introduction 4 min read PHP Database connection 2 min read PHP | MySQL ( Creating Database ) 3 min read PHP | MySQL ( Creating Table ) 3 min read PHP AdvancePHP Superglobals 6 min read PHP | Regular Expressions 12 min read PHP Form Handling 4 min read PHP File Handling 4 min read PHP | Uploading File 3 min read PHP Cookies 9 min read PHP | Sessions 7 min read Like