Date Formatter
Format dates in ISO, Unix timestamp, and custom patterns. Convert between date formats easily.
Select Date & Time
Custom Format
All Formats
Format Tokens Reference
YYYYFull year (2024)YY2-digit year (24)MMMMFull month (January)MMMShort month (Jan)MM2-digit month (01)DD2-digit day (05)DDDDFull weekday (Monday)DDDShort weekday (Mon)HH24-hour (14)hh12-hour (02)mmMinutes (30)ssSeconds (45)AAM/PMWhat Is a Date Formatter?
A date formatter is a tool that takes a single date and time value and converts it into multiple standardized representations simultaneously. Whether you need an ISO 8601 string for a REST API, a Unix timestamp for database storage, a US-style MM/DD/YYYY for a form field, or a fully customized pattern like DDDD, MMMM D YYYY for a document header, a date formatter gives you all of these in one click.
Dates are one of the most notoriously inconsistent data types in software. The same moment in time — say, June 7 2026 at 3:45 PM — can legitimately be written as 2026-06-07T15:45:00.000Z, 06/07/2026, 07/06/2026, 1749300300, Sunday, June 7, 2026 at 3:45:00 PM UTC, or Sun, 07 Jun 2026 15:45:00 GMT. Each of these representations is correct in its own context, yet they are completely different strings. Mixing them up is one of the most common sources of bugs in web applications, APIs, and data pipelines.
This calculator accepts a date and time input (using the browser's native datetime-local picker) and an optional custom format string using Moment.js-style tokens. It then outputs every common format at once, letting you click any row to copy the value to your clipboard instantly. The custom format engine supports tokens for year, month, day, weekday, 24-hour and 12-hour time, minutes, seconds, and AM/PM — making it adaptable to virtually any system you need to feed data into.
Custom Format Tokens and How They Work
The custom format field uses token-based substitution: you write a template string containing special token codes, and the formatter replaces each token with the corresponding date component. Tokens are processed in a specific order — longer tokens like YYYY and MMMM are replaced before shorter ones like YY and M — so they do not conflict with each other.
Understanding token precedence is important when building custom formats. For example, the template MMMM D, YYYY produces June 7, 2026 because MMMM matches the full month name token first, then D matches the day without zero-padding, and YYYY provides the four-digit year. If you wrote MM/DD/YYYY instead, you would get 06/07/2026 with zero-padded month and day.
The time tokens work on two parallel tracks: 24-hour (HH / H) and 12-hour (hh / h). For 12-hour time you should always pair the hour token with A (uppercase AM/PM) or a (lowercase am/pm). For example, hh:mm A produces 03:45 PM.
| Token | Description | Example |
|---|---|---|
| YYYY | Full 4-digit year | 2026 |
| YY | Last 2 digits of year | 26 |
| MMMM | Full month name | June |
| MMM | Abbreviated month name | Jun |
| MM | Zero-padded month (01–12) | 06 |
| M | Month without padding (1–12) | 6 |
| DDDD | Full weekday name | Sunday |
| DDD | Abbreviated weekday | Sun |
| DD | Zero-padded day (01–31) | 07 |
| D | Day without padding (1–31) | 7 |
| HH | 24-hour zero-padded (00–23) | 15 |
| H | 24-hour without padding | 15 |
| hh | 12-hour zero-padded (01–12) | 03 |
| h | 12-hour without padding | 3 |
| mm | Zero-padded minutes | 45 |
| ss | Zero-padded seconds | 00 |
| A | Uppercase AM or PM | PM |
| a | Lowercase am or pm | pm |
Custom Format Token Substitution
Where:
- template= The custom format string entered by the user
- year= date.getFullYear() — 4-digit year
- month= date.getMonth() + 1 — month number 1–12
- day= date.getDate() — day of month 1–31
- dow= date.getDay() — day of week 0 (Sun) to 6 (Sat)
- H24= date.getHours() — 24-hour value 0–23
- H12= hours % 12 || 12 — 12-hour value 1–12
- ampm= hours >= 12 ? 'PM' : 'AM'
- pad(n)= String(n).padStart(2, '0') — zero-pad to 2 digits
All Built-In Date Formats Explained
Beyond the custom format field, the date formatter automatically calculates 13 additional standard formats. Each serves a distinct purpose in development, data exchange, or user-facing display.
ISO 8601 (date.toISOString()) is the international standard for machine-readable dates. It always outputs in UTC, using the format YYYY-MM-DDTHH:mm:ss.sssZ. The trailing Z denotes UTC (Zulu time). This is the format used by JSON APIs, HTTP headers, and most modern databases. Because it sorts lexicographically in the correct chronological order, it is also ideal for filenames and log entries.
ISO Date strips the time component, giving just YYYY-MM-DD. This is the format used by HTML date input fields, SQL DATE columns, and many CSV exports.
Unix Timestamp represents the date as the number of whole seconds elapsed since the Unix epoch (January 1, 1970 00:00:00 UTC). It is computed as Math.floor(date.getTime() / 1000). Unix timestamps are timezone-agnostic and are used ubiquitously in server logs, databases, and POSIX systems.
Unix (ms) is the same value without the floor division — date.getTime() — giving milliseconds since the epoch. JavaScript's Date object natively works in milliseconds, so this is useful when passing timestamps directly to JavaScript APIs.
US Format (MM/DD/YYYY) is the conventional American date format. EU Format (DD/MM/YYYY) flips day and month, as used across most of Europe. These two formats are a frequent source of confusion and bugs when processing user-submitted data — always validate which convention the source uses.
Long Date uses toLocaleDateString with weekday: 'long', producing strings like Sunday, June 7, 2026. Short Date drops the weekday and abbreviates the month: Jun 7, 2026. Both are suitable for display in user interfaces where readability matters more than parsability.
RFC 2822 (date.toUTCString()) is the format used in email headers and some HTTP headers, producing strings like Sun, 07 Jun 2026 15:45:00 GMT.
Relative time computes the difference between the selected date and now: diff = date.getTime() - now.getTime(). If diff < 0 the date is in the past and the result reads N days ago; otherwise it reads in N days. The largest applicable unit (days → hours → minutes → seconds) is chosen for display.
When to Use Each Date Format
Choosing the right date format for a given situation is a skill that prevents countless integration bugs. Here is a practical guide to the most common use cases for each format produced by this date format converter.
- ISO 8601 full string — Use this for API request/response bodies, JSON payloads, event logs, and any data that crosses timezone boundaries. The UTC offset is explicit, making the timestamp unambiguous anywhere in the world.
- ISO Date (YYYY-MM-DD) — Use this for database
DATEcolumns, HTML input values, URL query parameters containing dates, and filenames (report-2026-06-07.csv). - Unix Timestamp (seconds) — Use this for POSIX-compatible systems, server logs, cron-based scheduling, and database fields where you want arithmetic on dates (adding days = adding 86400). Python's
datetime.fromtimestamp(), PHP'sdate(), and most server-side languages accept this natively. - Unix (ms) — Use this for JavaScript's
new Date(timestamp), browserperformance.now()comparisons, and any JS-first data pipeline. - US and EU formats — Use these only for display purposes when you know your audience's locale. Never use slash-separated formats as input to a parser without specifying the format explicitly.
- Long / Short Date — Use these in user interfaces: confirmation screens, receipts, calendar widgets, and localized product pages.
- RFC 2822 — Use this in email headers (
Date:field), HTTPLast-Modifiedheaders, and RSS/Atom feed timestamps. - Custom format — Use this when a third-party system mandates a non-standard pattern, such as a legacy ERP system that expects
DD-MMM-YYYY(e.g., 07-Jun-2026) or a report generator that needsMMMM D, YYYY.
As a general rule: use ISO 8601 for machine-to-machine communication, locale-aware long/short formats for human-facing display, and Unix timestamps for storage and arithmetic.
Timezones, UTC, and Local Time
One of the most important nuances in date formatting is understanding the difference between local time and UTC (Coordinated Universal Time). The browser's datetime-local input always works in your local timezone. When you select June 7 2026 at 3:45 PM, the JavaScript Date object stores that moment as UTC internally — but the displayed hours, minutes, and day components are your local time.
This means the ISO 8601 full string output may show a different hour than your input. For example, if you are in UTC-5 (US Eastern) and select 3:45 PM, the ISO output will show 2026-06-07T20:45:00.000Z — that's 20:45 UTC, which is the same moment as 3:45 PM Eastern. This is correct behavior: ISO 8601 always expresses time in UTC.
The time (24h), time (12h), and custom format outputs use local time components (getHours(), getMinutes(), getSeconds()), so they will show the time as you entered it. The Unix timestamp is always UTC-based regardless of local timezone — it counts seconds from the epoch in UTC, making it the safest format for cross-timezone storage.
When building date-handling systems, a best practice is to store everything as UTC (ISO 8601 or Unix timestamp) and convert to local time only at the display layer. This avoids ambiguities caused by daylight saving time transitions, where the same local clock time can occur twice in a single day.
Worked Examples
Format a Meeting Time for an International API
Problem:
You have a meeting scheduled for March 15, 2026 at 2:30 PM local time and need to send it to a REST API that requires ISO 8601.
Solution Steps:
- 1Enter 2026-03-15T14:30 into the date-time picker.
- 2The ISO 8601 output reads 2026-03-15T14:30:00.000Z (assuming UTC local), giving a fully qualified timestamp.
- 3Copy the ISO 8601 value from the results panel with one click.
- 4The Unix Timestamp output (1742046600) can also be stored in a database integer column for easy arithmetic.
Result:
ISO 8601: 2026-03-15T14:30:00.000Z | Unix Timestamp: 1742046600
Build a Custom Format for a Legacy Report System
Problem:
A legacy ERP system requires dates in the format 'DD-MMM-YYYY' (e.g., 07-Jun-2026). Create a custom format string for June 7 2026.
Solution Steps:
- 1Enter 2026-06-07T00:00 as the date.
- 2In the Custom Format field, type DD-MMM-YYYY.
- 3The formatter replaces DD with 07, MMM with Jun, and YYYY with 2026.
- 4The Custom Format output row shows 07-Jun-2026, ready to paste into the ERP form.
Result:
Custom Format output: 07-Jun-2026
Get the Full Weekday Name for a UI Header
Problem:
You want to display 'Sunday, June 7, 2026' as a greeting header on a dashboard for the date June 7, 2026.
Solution Steps:
- 1Select 2026-06-07 in the date picker (June 7 2026 is a Sunday).
- 2Use the custom format DDDD, MMMM D, YYYY.
- 3The formatter looks up dayNames[0] = 'Sunday' for DDDD, monthNames[5] = 'June' for MMMM, day = 7 for D (no padding), year = 2026 for YYYY.
- 4Output: Sunday, June 7, 2026 — copy and paste directly into the UI template.
Result:
Custom Format output: Sunday, June 7, 2026
Convert a Date to Relative Time Display
Problem:
You want to show how long ago an event occurred — the event happened on June 1, 2026 and today is June 7, 2026.
Solution Steps:
- 1Enter 2026-06-01T00:00 in the date picker.
- 2The formatter computes diff = June 1 - June 7 = -518400000 ms, which is negative (past).
- 3absDiff / 1000 = 518400 seconds; / 60 = 8640 minutes; / 60 = 144 hours; / 24 = 6 days.
- 4Since days > 0, relative = '6 days'; isPast = true, so output is '6 days ago'.
Result:
Relative: 6 days ago
Tips & Best Practices
- ✓Use ISO 8601 for all API and database communication — it is unambiguous, sortable, and universally supported.
- ✓Store dates as Unix timestamps in your database for easy arithmetic and timezone-safe comparisons.
- ✓Always pair 12-hour tokens (hh or h) with AM/PM tokens (A or a) to avoid ambiguous output.
- ✓Use DD-MMM-YYYY format (e.g., 07-Jun-2026) when you need human readability without ambiguity between US and EU conventions.
- ✓Click any output row to copy it to your clipboard — no need to manually select the text.
- ✓Use the 'Now' button to instantly format the current date and time without typing.
- ✓The EU format (DD/MM/YYYY) and US format (MM/DD/YYYY) are indistinguishable when the day is 12 or less — always prefer ISO dates for data exchange.
- ✓The relative time output auto-updates based on the current moment each time you interact with the tool — refresh the page to get a fresh 'now' baseline.
Frequently Asked Questions
Sources & References
Last updated: 2026-06-05
Help us improve!
How would you rate the Date Formatter?
Editorial Note
MyCalcBuddy Editorial Team
This page is maintained as an educational calculator reference.
Formula Source: Standard Mathematical References
by Various