Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

getdate()

Example

Return the date and time information for the current local date and time.

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

Definition and Usage

The getdate() function returns date and time information for a specified timestamp or the current local date and time if no timestamp is provided.

Syntax

getdate(timestamp)

Parameter Values

Parameter

Description

timestamp

Optional. Specifies an integer Unix timestamp; defaults to the current local time (time()) if not provided.

Technical Details

 

Return Value:

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 (0=Sunday, 1=Monday,…)
  • [mon] – month
  • [year] – year
  • [yday] – day of the year
  • [weekday] – name of the weekday
  • [month] – name of the month

[0] – seconds since Unix Epoch

PHP Version:

4+