PHP getdate() Function

In this chapter you will learn:

  1. Definition for PHP getdate() Function
  2. Syntax for PHP getdate() Function
  3. Parameter for PHP getdate() Function
  4. Return value for PHP getdate() Function
  5. Example - Return date/time information of the current local date/time

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.

Next chapter...

What you will learn in the next chapter:

  1. Definition for PHP gettimeofday() Function
  2. Syntax for PHP gettimeofday() Function
  3. Parameter for PHP gettimeofday() Function
  4. Return value for PHP gettimeofday() Function
  5. Example - Return the current time
Home » PHP Tutorial » PHP Date Functions
PHP checkdate() Function
PHP date() Function
PHP date_add() Function
PHP date_create() Function
PHP date_create_from_format() Function
PHP date_date_set() Function
PHP date_default_timezone_get() Function
PHP date_default_timezone_set() Function
PHP date_diff() Function
PHP date_format() Function
PHP date_get_last_errors() Function
PHP date_interval_format() Function
PHP date_isodate_set() Function
PHP date_modify() Function
PHP date_offset_get() Function
PHP date_parse() Function
PHP date_parse_from_format() Function
PHP date_sub() Function
PHP date_sun_info() Function
PHP date_sunrise() Function
PHP date_sunset() Function
PHP date_time_set() Function
PHP date_timestamp_get() Function
PHP date_timestamp_set() Function
PHP date_timezone_get() Function
PHP date_timezone_set() Function
PHP getdate() Function
PHP gettimeofday() Function
PHP gmdate() Function
PHP gmmktime() Function
PHP gmstrftime() Function
PHP idate() Function
PHP localtime() Function
PHP microtime() Function
PHP mktime() Function
PHP strftime() Function
PHP strptime() Function
PHP strtotime() Function
PHP time() Function
PHP Timezones Constant
PHP timezone_abbreviations_list() Function
PHP timezone_identifiers_list() Function
PHP timezone_location_get() Function
PHP timezone_name_from_abbr() Function
PHP timezone_name_get() Function
PHP timezone_offset_get() Function
PHP timezone_open() Function
PHP timezone_version_get() Function