PHP Date Format Generator

Build PHP date() format strings and preview the result.

Type PHP format letters, or tap them below to insert them where the cursor is.

Common formats
Output 2026-12-06 01:17:35

PHP code
echo date('Y-m-d H:i:s');
echo (new DateTime())->format('Y-m-d H:i:s');

Letters are escaped with a backslash so PHP prints them as they are.

Day

LetterMeaningNow
Day of the month, 2 digits 06
Short day name Sun
Day of the month 6
Full day name Sunday
Day of week, 1 (Mon) to 7 (Sun) 7
English suffix: st, nd, rd, th th
Day of week, 0 (Sun) to 6 (Sat) 0
Day of the year, from 0 339

Week

LetterMeaningNow
ISO week number 49

Month

LetterMeaningNow
Full month name December
Month, 2 digits 12
Short month name Dec
Month 12
Days in the month 31

Year

LetterMeaningNow
1 if leap year, else 0 0
ISO week-numbering year 2026
Full year 2026
Year, 2 digits 26

Time

LetterMeaningNow
am or pm am
AM or PM AM
Hour, 12-hour 1
Hour, 24-hour 1
Hour, 12-hour, 2 digits 01
Hour, 24-hour, 2 digits 01
Minutes 17
Seconds 35
Microseconds 000000
Milliseconds 000
Swatch Internet time 095

Time zone

LetterMeaningNow
Time zone name UTC
1 if daylight saving time 0
Offset, +0530 +0000
Offset, +05:30 +00:00
Like P, but Z for UTC Z
Abbreviation UTC
Offset in seconds 0

Full date

LetterMeaningNow
ISO 8601 2026-12-06T01:17:35+00:00
RFC 2822 Sun, 06 Dec 2026 01:17:35 +0000
Unix timestamp 1796519855

Use this tool on EWD Labs

This copy of the tool can't run here. Open the original, free version instead.

Open PHP Date Format Generator

Runs in your browser. Nothing you type is uploaded.

How to use the PHP date format generator

  1. Pick a common format, or type your own using PHP's format letters.
  2. Tap any letter in the tables to insert it where your cursor is. Each row shows what it prints right now.
  3. Use Add your own words for text such as "at" or "on". The letters are escaped with a backslash so PHP doesn't treat them as format codes.
  4. Copy the ready-made date() or DateTime::format() code.

The preview follows PHP's own rules, including ISO week numbers, the English suffixes st, nd, rd and th, and time zone offsets. Pick a time zone and a date to see exactly what your server will print.

Worked example

The format l, jS F Y \a\t g:ia on January 1, 2026 at 5:30 in the morning prints:

Thursday, 1st January 2026 at 5:30am

  • l is the full day name and jS is the day with its suffix.
  • F Y is the full month name and four-digit year.
  • \a\t prints the word "at", and g:ia is the 12-hour time with am or pm.

Time zone abbreviations (the T letter) come from your browser and can differ slightly from your server's time zone database for a few zones.

Frequently asked questions

What is the difference between date() and DateTime::format()?

They use the same format letters and print the same result. DateTime is better for new code because it handles time zones and date maths more safely.

How do I print a letter as normal text?

Put a backslash before it, such as \a\t for the word "at". Use Add your own words and the tool escapes the letters for you.

Why does my server show a different time?

PHP uses the time zone set in php.ini or by date_default_timezone_set(). Pick the same zone here to preview what your server prints.