Date Formatter

Format dates in ISO, Unix timestamp, and custom patterns. Convert between date formats easily.

Select Date & Time

Custom Format

All Formats

ISO 8601
2026-07-17T01:13:00.000Z
ISO Date
2026-07-17
Unix Timestamp
1784250780
Unix (ms)
1784250780000
US Format
07/17/2026
EU Format
17/07/2026
Long Date
Friday, July 17, 2026
Short Date
Jul 17, 2026
Time (24h)
06:43:00
Time (12h)
6:43:00 AM
Full DateTime
Friday, July 17, 2026 at 6:43:00 AM GMT+5:30
RFC 2822
Fri, 17 Jul 2026 01:13:00 GMT
Relative
5 hours ago
Custom Format
2026-07-17

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/PM

What 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
YYYYFull 4-digit year2026
YYLast 2 digits of year26
MMMMFull month nameJune
MMMAbbreviated month nameJun
MMZero-padded month (01–12)06
MMonth without padding (1–12)6
DDDDFull weekday nameSunday
DDDAbbreviated weekdaySun
DDZero-padded day (01–31)07
DDay without padding (1–31)7
HH24-hour zero-padded (00–23)15
H24-hour without padding15
hh12-hour zero-padded (01–12)03
h12-hour without padding3
mmZero-padded minutes45
ssZero-padded seconds00
AUppercase AM or PMPM
aLowercase am or pmpm

Custom Format Token Substitution

output = template.replace(YYYY, year).replace(YY, year.slice(-2)).replace(MMMM, monthNames[month-1]).replace(MMM, shortMonths[month-1]).replace(MM, pad(month)).replace(M, month).replace(DDDD, dayNames[dow]).replace(DDD, shortDays[dow]).replace(DD, pad(day)).replace(D, day).replace(HH, pad(H24)).replace(H, H24).replace(hh, pad(H12)).replace(h, H12).replace(mm, pad(min)).replace(m, min).replace(ss, pad(sec)).replace(s, sec).replace(A, ampm).replace(a, ampm.toLowerCase())

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 DATE columns, 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's date(), and most server-side languages accept this natively.
  • Unix (ms) — Use this for JavaScript's new Date(timestamp), browser performance.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), HTTP Last-Modified headers, 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 needs MMMM 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:

  1. 1Enter 2026-03-15T14:30 into the date-time picker.
  2. 2The ISO 8601 output reads 2026-03-15T14:30:00.000Z (assuming UTC local), giving a fully qualified timestamp.
  3. 3Copy the ISO 8601 value from the results panel with one click.
  4. 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:

  1. 1Enter 2026-06-07T00:00 as the date.
  2. 2In the Custom Format field, type DD-MMM-YYYY.
  3. 3The formatter replaces DD with 07, MMM with Jun, and YYYY with 2026.
  4. 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:

  1. 1Select 2026-06-07 in the date picker (June 7 2026 is a Sunday).
  2. 2Use the custom format DDDD, MMMM D, YYYY.
  3. 3The formatter looks up dayNames[0] = 'Sunday' for DDDD, monthNames[5] = 'June' for MMMM, day = 7 for D (no padding), year = 2026 for YYYY.
  4. 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:

  1. 1Enter 2026-06-01T00:00 in the date picker.
  2. 2The formatter computes diff = June 1 - June 7 = -518400000 ms, which is negative (past).
  3. 3absDiff / 1000 = 518400 seconds; / 60 = 8640 minutes; / 60 = 144 hours; / 24 = 6 days.
  4. 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

ISO 8601 is the full timestamp including time and UTC offset, like 2026-06-07T15:45:00.000Z. ISO Date strips the time portion and returns only the date part YYYY-MM-DD (e.g., 2026-06-07). Use ISO Date when you only need the calendar date without time information, such as for HTML date inputs or SQL DATE columns.
The browser's datetime-local input stores your entry in local time, but date.toISOString() always outputs in UTC. If you are in a timezone behind UTC (e.g., UTC-5), the ISO string will show your local time plus the UTC offset. For example, entering 3:00 PM in UTC-5 produces T20:00:00.000Z. This is correct and expected behavior.
A Unix timestamp is the number of whole seconds elapsed since January 1, 1970 00:00:00 UTC, computed as Math.floor(date.getTime() / 1000). It is timezone-agnostic — it always represents a specific, unambiguous moment in time. Storing dates as Unix timestamps makes sorting, comparing, and arithmetic (adding days = adding 86400) trivial without any string parsing, and they are supported natively by virtually every programming language and database.
Yes — format tokens can be arranged in any order with any separator characters you like. For example, YYYY/MM/DD, DD.MM.YYYY, MMMM D YYYY, and hh:mm A on DDDD all work correctly. Separators like slashes, dashes, dots, commas, and spaces are passed through unchanged because they are not recognized tokens. Just be aware that the token replacement is order-sensitive: YYYY is replaced before YY, MMMM before MMM before MM, etc., so there is no ambiguity.
RFC 2822 is the date format defined in the email message standard (now updated by RFC 5322). It produces strings like Sun, 07 Jun 2026 15:45:00 GMT, generated by date.toUTCString() in JavaScript. This format is used in email Date: headers, HTTP Last-Modified and Expires headers, and some RSS and Atom feed timestamps. It is human-readable but less ideal for machine parsing than ISO 8601.
The relative time output computes diff = selectedDate.getTime() - now.getTime() in milliseconds. If diff is negative the date is in the past. The absolute difference is converted to seconds, then minutes, hours, and days by successive integer division. The largest non-zero unit is chosen: days first, then hours, then minutes, then seconds. The result is labeled 'N units ago' for past dates or 'in N units' for future dates.
The custom format tokens (HH, hh, mm, ss) reflect local time as entered in the picker. The tool does not expose timezone offset tokens (like Z or +HH:MM) in the custom format engine. For timezone-aware output, use the ISO 8601 or RFC 2822 built-in formats, both of which include explicit UTC information.

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.

Source

Formula Source: Standard Mathematical References

by Various

UpdatedLast reviewed: May 2026
CheckedFormula checks are based on standard references and internal QA review.