PHP Date Format Example

Format dates and times with date() and DateTime. Edit the code below and press Run to execute it with real PHP in your browser.

Code Editor
Output
Full: Sunday, March 15, 2026
ISO: 2026-03-15
Time: 14:30:00
12-hour: Mar 15, 2026 - 02:30 PM
Next month: 2026-04-15

How this date format example works

date() formats a Unix timestamp (the current time if omitted) using format characters: Y four-digit year, m month, d day, H 24-hour, h 12-hour, i minutes, A AM/PM, l weekday name. This example uses a fixed timestamp so the output is predictable; remove the second argument to format the current date. DateTime is better for date arithmetic and time zones.