PHP getdate() Function

Example

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

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

Running Instance

Definition and Usage

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

Syntax

getdate(timestamp);
Parameter Description
timestamp Optional. Specifies a Unix timestamp, an integer value. Default is 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] - Since the Unix epoch in seconds
PHP Version: 4+