PHP getdate() Function

Definition

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

Syntax

PHP getdate() Function has the following syntax.

getdate(timestamp);

Parameter

PHP getdate() Function has the following parameter.

timestamp - Optional. An integer Unix timestamp. Default is the current local time (time())

Return

PHP getdate() Function returns an associative array with information related to 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

Example

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


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

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions