Date Functions

PHP manipulates dates in a number of ways, using arrays, strings, Unix timestamps, or DateTime objects. PHP provides a number of built-in functions for manipulating dates using these various data types.

Date Functions

date_create()
Creates a new DateTime object from a formatted date-time string.
date_format()
Takes a DateTime object and returns a string based on its formatted value.
date()
Creates a formatted date-time string from a local date-time.
getdate()
Returns an array representing the current date or a Unix timestamp.
time()
Returns current time measured in seconds from the Unix Epoch.

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn PHP on Codecademy