W3docs

Tools

Date Format Tester

See one moment rendered by PHP date(), Python strftime, Java DateTimeFormatter and JavaScript Intl, in any time zone. Everything runs in your browser — your timestamps and patterns never leave your device.

Instant and time zone

Runs in your browser: nothing you enter is sent anywhere.

Unix seconds
1709647629
Unix milliseconds
1709647629123
ISO 8601 (UTC)
2024-03-05T14:07:09.123Z
Wall clock in UTC
Tue, 2024-03-05 14:07:09.123 (UTC+00:00)

PHP date()

DateTimeInterface::format, PHP 8.x

Examples:
Result

Click a token to insert it

PHP date() tokens
TokenMeaningOutput
Day of the month, 2 digits05
Day of the month, no leading zero5
Day name, 3 lettersTue
Day name, fullTuesday
ISO day of week, 1 (Mon) to 7 (Sun)2
Day of week, 0 (Sun) to 6 (Sat)2
English ordinal suffix for jth
Day of the year, from 064
ISO week number10
Month name, fullMarch
Month name, 3 lettersMar
Month, 2 digits03
Month, no leading zero3
Days in the month31
Leap year: 1 or 01
Year, at least 4 digits2024
Year, 2 digits24
ISO week-numbering year2024
Year, always signed (PHP 8.2+)+2024
Year, signed past 9999 (PHP 8.2+)2024
am or pmpm
AM or PMPM
Hour 1–122
Hour 01–1202
Hour 0–2314
Hour 00–2314
Minutes, 2 digits07
Seconds, 2 digits09
Milliseconds123
Microseconds123000
Swatch Internet time629
Time zone identifierUTC
Time zone abbreviationUTC
Daylight saving time: 1 or 00
UTC offset, +0200+0000
UTC offset, +02:00+00:00
Like P, but Z for UTC (PHP 8.0+)Z
UTC offset in seconds0
ISO 8601 date and time2024-03-05T14:07:09+00:00
RFC 2822 date and timeTue, 05 Mar 2024 14:07:09 +0000
Unix timestamp, seconds1709647629
Escape: print the next character as is—

Python strftime

datetime.strftime with zoneinfo, Python 3.12+

Examples:
Result

Click a token to insert it

Python strftime tokens
TokenMeaningOutput
Day of the month, 2 digits05
Day name, 3 lettersTue
Day name, fullTuesday
Day of week, 0 (Sun) to 6 (Sat)2
ISO day of week, 1 (Mon) to 7 (Sun)2
Day of the year, 3 digits065
Week of the year (Sunday first)09
Week of the year (Monday first)10
ISO week number10
Month name, 3 lettersMar
Month name, fullMarch
Month, 2 digits03
Year, 2 digits24
Year, 4 digits2024
ISO week-numbering year2024
Hour 00–2314
Hour 01–1202
AM or PMPM
Minutes, 2 digits07
Seconds, 2 digits09
Microseconds, 6 digits123000
UTC offset, +0200+0000
UTC offset, +02:00 (Python 3.12+)+00:00
Time zone nameUTC
Locale date and time (C locale)Tue Mar 5 14:07:09 2024
Locale date (C locale)03/05/24
Locale time (C locale)14:07:09
A literal %%

Java DateTimeFormatter

DateTimeFormatter.ofPattern(p, Locale.ENGLISH), Java 17+

Examples:
Result

Click a token to insert it

Java DateTimeFormatter tokens
TokenMeaningOutput
Year of era, 4 digits2024
Year, 2 digits24
Proleptic year (negative before 1 AD)2024
Week-based year (differs near New Year)2024
Era, AD or BCAD
Quarter number1
Quarter, full text1st quarter
Month, no leading zero3
Month, 2 digits03
Month name, 3 lettersMar
Month name, fullMarch
Day of the month5
Day of the month, 2 digits05
Day of the year65
Week of week-based year (Sunday first)10
Week of the month2
Day name, 3 lettersTue
Day name, fullTuesday
Day of week number, 1 = Sunday3
Aligned week of the month1
AM or PMPM
Day period, e.g. in the morningin the afternoon
Hour 1–122
Hour 01–1202
Hour 0–112
Hour 1–2414
Hour 0–2314
Hour 00–2314
Minutes, 2 digits07
Seconds, 2 digits09
Fraction of second, 3 digits123
Nanosecond of second123000000
Millisecond of day50829123
Time zone IDUTC
Time zone short nameUTC
Time zone full nameCoordinated Universal Time
Generic zone nameUTC
Localized offset, GMT+2GMT
Offset +02:00, Z for zeroZ
Offset +0200+0000
Offset +0200+0000
Literal text in single quotesat
A literal single quote'
Optional section

JavaScript Intl.DateTimeFormat

new Intl.DateTimeFormat('en-US', options), your browser's engine

Examples:
Result

JavaScript has no pattern strings: Intl takes an options object. The time zone always comes from the picker above.

Click a token to insert it

JavaScript Intl.DateTimeFormat tokens
TokenMeaningOutput
Whole date, longest formTuesday, March 5, 2024
Whole date, abbreviatedMar 5, 2024
Whole date, numeric3/5/24
Time with zone name2:07:09 PM UTC
Hours and minutes2:07 PM
Day nameTuesday
AD / BC3/5/2024 AD
Year2024
Year, 2 digits24
Month nameMarch
Month, 2 digits03
Day of the month5
Hour02 PM
Minutes7
Seconds9
Milliseconds123
24-hour clock3/5/2024
12-hour clock3/5/2024
in the morning…in the afternoon
Zone, e.g. EST3/5/2024, UTC
Zone, full name3/5/2024, Coordinated Universal Time
Zone as GMT-53/5/2024, GMT+0
Zone as GMT-05:003/5/2024, GMT+00:00

About the date format tester

Pick one moment in time and one time zone, then type a format pattern and watch it render the way PHP date(), Python strftime, Java DateTimeFormatter and JavaScript Intl.DateTimeFormat would print it. Each language has its own box, because each uses its own codes: Y-m-d in PHP is %Y-%m-%d in Python and yyyy-MM-dd in Java, while JavaScript takes an options object instead of a pattern. Results update as you type, and the token tables beside each box show what every code prints for the instant you chose. Click a token to insert it at the cursor.

The instant is absolute: enter it as a Unix timestamp in seconds or milliseconds, or as a UTC date and time, and the time zone only decides how it is displayed. Zones are IANA names such as America/New_York, Asia/Kolkata (UTC+5:30) or Asia/Kathmandu (UTC+5:45), and daylight saving time is applied for the exact date, so T in PHP prints EST in winter and EDT in summer. Zone abbreviations come from the same data PHP, Python and Java ship with, sampled from 1970 to 2037; before 1970 the tool says so next to the result.

A code a language does not have is never guessed. Java rejects unknown letters such as b or a missing closing quote, so the tool shows Java’s own error and no output. Python codes outside the documented list (%-d, %e, %s) change with the operating system, so they are flagged by name. PHP copies any character that is not a format code as is, exactly as PHP does. Everything runs in your browser: the timestamp, zone and patterns are never sent to a server.

Worked examples

All three use the instant 1709647629123 ms (2024-03-05T14:07:09.123Z) shown in the America/New_York zone, which is UTC−05:00 in March before DST starts.

PHP: escaping letters you want literallyphp
$d = new DateTimeImmutable('@1709647629.123');
$d = $d->setTimezone(new DateTimeZone('America/New_York'));
echo $d->format('l, jS \\of F Y, g:i A T (P)');
// Tuesday, 5th of March 2024, 9:07 AM EST (-05:00)

In the tester you type the pattern with single backslashes: l, jS \of F Y, g:i A T (P). Without the backslashes, o and f would be read as the ISO year and nothing.

Python: the same moment with strftimepython
from datetime import datetime
from zoneinfo import ZoneInfo

d = datetime.fromtimestamp(1709647629.123, ZoneInfo('America/New_York'))
print(d.strftime('%A, %d %B %Y %I:%M %p %Z (%z)'))
# Tuesday, 05 March 2024 09:07 AM EST (-0500)

Python pads the day (%d) and 12-hour clock (%I) with zeros. %-d would drop the zero on Linux and macOS but fails on Windows, which is why the tester flags it.

Java: y versus Y at New Yearjava
var f = DateTimeFormatter.ofPattern("y Y w", Locale.ENGLISH);
var d = Instant.parse("2023-12-31T12:00:00Z").atZone(ZoneId.of("UTC"));
System.out.println(f.format(d)); // 2023 2024 1

Y is the week-based year: with English weeks starting on Sunday, 31 December 2023 already belongs to week 1 of 2024. Use y or u for the calendar year.

Frequently asked questions

Why does the time zone not change the Unix timestamp?

A Unix timestamp counts seconds since 1970-01-01T00:00:00Z and is the same everywhere. The time zone only changes the wall-clock fields and zone names that a pattern prints.

What is the difference between T in PHP, %Z in Python and z in Java?

All three print a short zone name, but from different sources. PHP and Python use the tz database abbreviation (CET, IST, or a number such as +04 for Dubai); Java uses its own names (CET, IST, GST for Dubai).

Why does Java show an error for my pattern?

DateTimeFormatter rejects letters it does not define (b, f, I, J…), too many repeats of a letter (ddd), and an unclosed single quote. Put literal words in single quotes, for example HH:mm 'o''clock'.

Which Python codes are supported?

The ones the Python documentation lists: %a %A %w %d %b %B %m %y %Y %H %I %p %M %S %f %z %:z %Z %j %U %W %c %x %X %G %u %V and %%. Others are passed to the C library and differ between Linux, macOS and Windows, so the tester names them instead of guessing.

How do I get milliseconds or microseconds?

PHP v prints milliseconds and u microseconds. Python %f prints microseconds. Java SSS prints milliseconds and SSSSSS microseconds. In JavaScript use the option fractionalSecondDigits: 3.

Is anything I type sent to a server?

No. The four formatters run in your browser, and JavaScript results come from your browser’s own Intl engine. The page makes no network request with your input.