PHP date()
Published May 23, 2022
Contribute to Docs
The date() function creates a formatted date-time string from a local date-time.
Syntax
$datestring = date($format, $timestamp);
The $format string is a string specifying how the date/time is to be formatted. It uses the same syntax as the date_format() function.
The $timestamp parameter is a Unix timestamp, the date-time expressed as seconds elapsed from the Unix Epoch (Midnight GMT, January 1st, 1970). It is optional, and if omitted or NULL it defaults to the current local date and time.
Codebyte Example
The example below prints the current date and time using the date() function.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn PHP on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours