Build a PHP date() or DateTime::format() string with a live preview in any time zone, plus a reference for every format character.
No account, uploads or PHP execution. Your inputs stay on this device.
A little context goes a long way
PHP date format characters
These work in date(), gmdate(), DateTime::format() and DateTimeImmutable::format(). Any other character is printed as is. To print a format letter literally, escape it with a backslash: \a\t prints "at". In double-quoted PHP strings, escape the backslash too, or use single quotes.
Day
Char
Meaning
Example
d
Day of the month, 2 digits with leading zeros (01 to 31)
D
Three-letter day name (Mon to Sun)
j
Day of the month without leading zeros (1 to 31)
l
Full day name (Sunday to Saturday)
N
ISO 8601 day of the week (1 = Monday, 7 = Sunday)
S
English ordinal suffix for the day (st, nd, rd, th); use after j
w
Day of the week (0 = Sunday, 6 = Saturday)
z
Day of the year, starting from 0 (0 to 365)
Week
Char
Meaning
Example
W
ISO 8601 week number (weeks start on Monday)
Month
Char
Meaning
Example
F
Full month name (January to December)
m
Month, 2 digits with leading zeros (01 to 12)
M
Three-letter month name (Jan to Dec)
n
Month without leading zeros (1 to 12)
t
Number of days in the month (28 to 31)
Year
Char
Meaning
Example
L
1 if it is a leap year, otherwise 0
o
ISO 8601 week-numbering year (pairs with W)
X
Expanded full year, at least 4 digits, - for BCE and + for years from 10000 (PHP 8.2+)
x
Expanded full year when needed, otherwise Y (PHP 8.2+)
Y
Full year, at least 4 digits
y
Two-digit year
Time
Char
Meaning
Example
a
am or pm
A
AM or PM
B
Swatch Internet time (000 to 999)
g
12-hour hour without leading zeros (1 to 12)
G
24-hour hour without leading zeros (0 to 23)
h
12-hour hour with leading zeros (01 to 12)
H
24-hour hour with leading zeros (00 to 23)
i
Minutes with leading zeros (00 to 59)
s
Seconds with leading zeros (00 to 59)
u
Microseconds (date() always gives 000000)
v
Milliseconds (date() always gives 000)
Time zone
Char
Meaning
Example
e
Time zone identifier (for example Europe/London)
I
1 if daylight saving time is in effect, otherwise 0
O
Difference to UTC without a colon (+0200)
P
Difference to UTC with a colon (+02:00)
p
Like P, but Z for +00:00
T
Time zone abbreviation, if known, else the offset
Z
Offset from UTC in seconds
Full date/time
Char
Meaning
Example
c
ISO 8601 date (2004-02-12T15:19:21+00:00)
r
RFC 2822 / RFC 5322 date (Thu, 21 Dec 2000 16:01:07 +0200)
U
Seconds since the Unix epoch
Common formats
MySQL DATETIME:Y-m-d H:i:s. Store UTC, convert on display.
ISO 8601 / RFC 3339 (APIs):DATE_ATOM or DateTimeInterface::ATOM, which is Y-m-d\TH:i:sP. c gives the same result.
HTTP headers:gmdate('D, d M Y H:i:s \G\M\T').
Day names in other languages:date() is English only. Use IntlDateFormatter; strftime() is deprecated since PHP 8.1.
Pitfalls
W with Y gives wrong labels around New Year: 1 January 2027 is in ISO week 53 of 2026. Pair W with o.
u is always 000000 with date(), which takes an integer timestamp. Use DateTime::format('u') for microseconds.
date() uses the date.timezone setting. Set it explicitly (date_default_timezone_set('UTC')) or pass a DateTimeZone to DateTimeImmutable.
n and j have no leading zero; m and d do. i is minutes, m is the month.