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
Click a token to insert it
| Token | Meaning | Output |
|---|---|---|
| Day of the month, 2 digits | 05 | |
| Day of the month, no leading zero | 5 | |
| Day name, 3 letters | Tue | |
| Day name, full | Tuesday | |
| ISO day of week, 1 (Mon) to 7 (Sun) | 2 | |
| Day of week, 0 (Sun) to 6 (Sat) | 2 | |
| English ordinal suffix for j | th | |
| Day of the year, from 0 | 64 | |
| ISO week number | 10 | |
| Month name, full | March | |
| Month name, 3 letters | Mar | |
| Month, 2 digits | 03 | |
| Month, no leading zero | 3 | |
| Days in the month | 31 | |
| Leap year: 1 or 0 | 1 | |
| Year, at least 4 digits | 2024 | |
| Year, 2 digits | 24 | |
| ISO week-numbering year | 2024 | |
| Year, always signed (PHP 8.2+) | +2024 | |
| Year, signed past 9999 (PHP 8.2+) | 2024 | |
| am or pm | pm | |
| AM or PM | PM | |
| Hour 1–12 | 2 | |
| Hour 01–12 | 02 | |
| Hour 0–23 | 14 | |
| Hour 00–23 | 14 | |
| Minutes, 2 digits | 07 | |
| Seconds, 2 digits | 09 | |
| Milliseconds | 123 | |
| Microseconds | 123000 | |
| Swatch Internet time | 629 | |
| Time zone identifier | UTC | |
| Time zone abbreviation | UTC | |
| Daylight saving time: 1 or 0 | 0 | |
| UTC offset, +0200 | +0000 | |
| UTC offset, +02:00 | +00:00 | |
| Like P, but Z for UTC (PHP 8.0+) | Z | |
| UTC offset in seconds | 0 | |
| ISO 8601 date and time | 2024-03-05T14:07:09+00:00 | |
| RFC 2822 date and time | Tue, 05 Mar 2024 14:07:09 +0000 | |
| Unix timestamp, seconds | 1709647629 | |
| Escape: print the next character as is | — |
Python strftime
datetime.strftime with zoneinfo, Python 3.12+
Click a token to insert it
| Token | Meaning | Output |
|---|---|---|
| Day of the month, 2 digits | 05 | |
| Day name, 3 letters | Tue | |
| Day name, full | Tuesday | |
| Day of week, 0 (Sun) to 6 (Sat) | 2 | |
| ISO day of week, 1 (Mon) to 7 (Sun) | 2 | |
| Day of the year, 3 digits | 065 | |
| Week of the year (Sunday first) | 09 | |
| Week of the year (Monday first) | 10 | |
| ISO week number | 10 | |
| Month name, 3 letters | Mar | |
| Month name, full | March | |
| Month, 2 digits | 03 | |
| Year, 2 digits | 24 | |
| Year, 4 digits | 2024 | |
| ISO week-numbering year | 2024 | |
| Hour 00–23 | 14 | |
| Hour 01–12 | 02 | |
| AM or PM | PM | |
| Minutes, 2 digits | 07 | |
| Seconds, 2 digits | 09 | |
| Microseconds, 6 digits | 123000 | |
| UTC offset, +0200 | +0000 | |
| UTC offset, +02:00 (Python 3.12+) | +00:00 | |
| Time zone name | UTC | |
| 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+
Click a token to insert it
| Token | Meaning | Output |
|---|---|---|
| Year of era, 4 digits | 2024 | |
| Year, 2 digits | 24 | |
| Proleptic year (negative before 1 AD) | 2024 | |
| Week-based year (differs near New Year) | 2024 | |
| Era, AD or BC | AD | |
| Quarter number | 1 | |
| Quarter, full text | 1st quarter | |
| Month, no leading zero | 3 | |
| Month, 2 digits | 03 | |
| Month name, 3 letters | Mar | |
| Month name, full | March | |
| Day of the month | 5 | |
| Day of the month, 2 digits | 05 | |
| Day of the year | 65 | |
| Week of week-based year (Sunday first) | 10 | |
| Week of the month | 2 | |
| Day name, 3 letters | Tue | |
| Day name, full | Tuesday | |
| Day of week number, 1 = Sunday | 3 | |
| Aligned week of the month | 1 | |
| AM or PM | PM | |
| Day period, e.g. in the morning | in the afternoon | |
| Hour 1–12 | 2 | |
| Hour 01–12 | 02 | |
| Hour 0–11 | 2 | |
| Hour 1–24 | 14 | |
| Hour 0–23 | 14 | |
| Hour 00–23 | 14 | |
| Minutes, 2 digits | 07 | |
| Seconds, 2 digits | 09 | |
| Fraction of second, 3 digits | 123 | |
| Nanosecond of second | 123000000 | |
| Millisecond of day | 50829123 | |
| Time zone ID | UTC | |
| Time zone short name | UTC | |
| Time zone full name | Coordinated Universal Time | |
| Generic zone name | UTC | |
| Localized offset, GMT+2 | GMT | |
| Offset +02:00, Z for zero | Z | |
| Offset +0200 | +0000 | |
| Offset +0200 | +0000 | |
| Literal text in single quotes | at | |
| A literal single quote | ' | |
| Optional section |
JavaScript Intl.DateTimeFormat
new Intl.DateTimeFormat('en-US', options), your browser's engine
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
| Token | Meaning | Output |
|---|---|---|
| Whole date, longest form | Tuesday, March 5, 2024 | |
| Whole date, abbreviated | Mar 5, 2024 | |
| Whole date, numeric | 3/5/24 | |
| Time with zone name | 2:07:09 PM UTC | |
| Hours and minutes | 2:07 PM | |
| Day name | Tuesday | |
| AD / BC | 3/5/2024 AD | |
| Year | 2024 | |
| Year, 2 digits | 24 | |
| Month name | March | |
| Month, 2 digits | 03 | |
| Day of the month | 5 | |
| Hour | 02 PM | |
| Minutes | 7 | |
| Seconds | 9 | |
| Milliseconds | 123 | |
| 24-hour clock | 3/5/2024 | |
| 12-hour clock | 3/5/2024 | |
| in the morning… | in the afternoon | |
| Zone, e.g. EST | 3/5/2024, UTC | |
| Zone, full name | 3/5/2024, Coordinated Universal Time | |
| Zone as GMT-5 | 3/5/2024, GMT+0 | |
| Zone as GMT-05:00 | 3/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.
$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.
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.
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 1Y 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.