PHP getdate() Function

Example

Return the date/time information for the current local date/time:

<?php
print_r(getdate());
?>

Running Example

Definition and Usage

The getdate() function returns a timestamp or date/time information for the current local date/time.

Syntax

getdate(timestamp);
Parameter Description
timestamp Optional. Specifies a Unix timestamp, integer value. Defaults to the current local time (time()).

Technical Details

Return value:

Return an associative array with information related to the timestamp:

  • [seconds] - Second
  • [minutes] - Minute
  • [hours] - Hour
  • [mday] - Day of the Month
  • [wday] - Day of the Week
  • [mon] - Month
  • [year] - Year
  • [yday] - Day of the Year
  • [weekday] - Name of the Day of the Week
  • [month] - Name of the Month
  • [0] - Seconds since Unix Epoch
PHP Version: 4+