PHP getdate() Function

Example

Returns the current local date/time information:

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

Run Example

Definition and Usage

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

Syntax

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

Technical Details

Return value:

Returns an associative array with information related to the timestamp:

  • [seconds] - The second
  • [minutes] - The minute
  • [hours] - The hour
  • [mday] - The day of the month
  • [wday] - The day of the week
  • [mon] - The month
  • [year] - The year
  • [yday] - The day of the year
  • [weekday] - The name of the day of the week
  • [month] - The name of the month
  • [0] - The number of seconds elapsed since the Unix epoch
PHP Version: 4+