JavaScript Date Formatter
Format JavaScript dates instantly with custom date patterns, time zones, locales, and Unix timestamps. Preview results and copy or download formatted dates directly in your browser.
Date Input
0 characters
Date interpretation depends on the selected input mode and display time zone. Date-only ISO values are treated as UTC; ISO date-times must include Z or a numeric offset.
Format Options
Uppercase M = month, lowercase m = minutes. Uppercase D = day of month, lowercase d = weekday name. Use [text] for literal text.
Formatted Output
Date Information
- Parsed date
- —
- ISO UTC string
- —
- Display time zone
- —
- Locale
- —
- Unix seconds
- —
- Unix milliseconds
- —
- UTC date and time
- —
- Local date and time
- —
- Year / Month / Day
- —
- Weekday
- —
- Hour / Minute / Second
- —
- Milliseconds
- —
All Developer Tools
Browse free online tools for JSON, HTML, CSS, XML, JavaScript, data conversion, and everyday development tasks.
Try a different search term or select another category.
What Is a JavaScript Date Formatter?
A JavaScript date formatter converts date values into readable, consistent formats for websites, applications, APIs, reports, and databases. It can turn an ISO date string or JavaScript Date object into a short date, long date, localized date and time, UTC string, or machine-readable timestamp.
JavaScript provides built-in date methods and the Intl.DateTimeFormat API for formatting dates. These tools let developers control how years, months, days, hours, minutes, and seconds appear, as well as which locale and timezone determine the displayed result.
Use a JavaScript date formatter to test date values, compare regional formats, prepare timestamps, and generate formatting code without repeatedly writing the same logic by hand.
Important: A date's displayed value depends on its timezone and locale. The same moment can appear as different calendar dates or times in different regions. Always identify whether your input represents a date only, a local date-time, or a specific moment in time.
How to Use a JavaScript Date Formatter Online
Follow these steps to format a date for your application or development workflow.
Provide an ISO date string, a supported date string, a Unix timestamp, or the current date if the tool offers that option.
Select a preset such as ISO 8601, a short date, a long date, a date-time string, or a custom format supported by the tool.
Choose a locale such as en-US or en-IN, and select UTC or an appropriate timezone when the formatter provides timezone controls.
Check the output for the expected date, time, timezone, and level of precision. Compare formats if you are preparing values for multiple systems.
Copy the formatted value into your application, documentation, API test, or database workflow. If code generation is available, reuse the generated snippet.
Quick JavaScript Date Formatting Examples
Convert a date to ISO 8601
Format a date for a US audience
Format a date in a specific timezone
Example: Format a JavaScript Date
Consider this ISO date-time value: 2026-10-15T10:30:00Z. The trailing Z indicates that the time is expressed in UTC. The same moment can be displayed in several formats depending on the intended use.
JavaScript input
Common output formats
| Format | Example output | Typical use |
|---|---|---|
| ISO 8601 | 2026-10-15T10:30:00.000Z |
APIs and machine-readable data |
| UTC string | Thu, 15 Oct 2026 10:30:00 GMT |
Readable UTC date-time output |
| US short date | 10/15/2026 |
US-facing interfaces |
| UK or India short date | 15/10/2026 |
Day-first date display |
| Long date | Thursday, October 15, 2026 |
Reports and content pages |
| Custom numeric date | 2026-10-15 |
Date fields and exports |
| Unix timestamp in seconds | 1792050600 |
Systems expecting Unix seconds |
| JavaScript timestamp | 1792050600000 |
JavaScript Date values |
Timestamp note: Unix timestamps count seconds from the Unix epoch, while JavaScript timestamps use milliseconds. When converting between them, multiply seconds by 1,000 to create a JavaScript timestamp, or divide milliseconds by 1,000 to get seconds.
JavaScript Date Input Formats
A date formatter may accept several kinds of input, but not every date string is interpreted consistently across environments. ISO date-time strings with an explicit timezone are generally the clearest choice when representing a specific moment.
| Input type | Example | What to know |
|---|---|---|
| ISO date-time in UTC | 2026-10-15T10:30:00Z |
Identifies a specific moment in UTC. |
| ISO date-time with offset | 2026-10-15T16:00:00+05:30 |
Includes the offset relative to UTC. |
| Date-only string | 2026-10-15 |
JavaScript interprets a standard date-only string as UTC midnight. |
| JavaScript timestamp | 1792050600000 |
Represents milliseconds since the Unix epoch. |
| Unix timestamp | 1792050600 |
Represents seconds since the Unix epoch; convert to milliseconds before passing it to Date. |
| Current time | Date.now() |
Returns the current timestamp in milliseconds. |
| Human-readable date string | October 15, 2026 |
May be accepted, but parsing behavior can be less predictable for non-standard strings. |
Best practice: Prefer standard ISO date-time strings with an explicit timezone for data exchange. Avoid ambiguous inputs such as 10/11/2026, which may mean October 11 or November 10 depending on the intended regional convention.
Common JavaScript Date Output Formats
Choose a date format based on where the value will be used. Machine-readable formats prioritize consistency, while localized formats prioritize readability for people.
ISO 8601
ISO output is useful for exchanging date-time values between services and storing timestamps in a standardized format.
Short Date
A short date displays the year, month, and day compactly. The order and separators depend on the selected locale.
Long Date
A long date spells out the month and may include the weekday, making it suitable for reports and readable content.
Date and Time
Use a combined date-time format for event schedules, audit records, activity feeds, and dashboard timestamps.
The exact punctuation and ordering depend on the locale and runtime.
UTC String
The toUTCString() method returns a human-readable representation of a date in UTC.
Unix Timestamp
A timestamp represents elapsed time from the Unix epoch. Seconds are common in APIs, while JavaScript uses milliseconds.
This returns the Unix timestamp in whole seconds.
Using Intl.DateTimeFormat in JavaScript
Intl.DateTimeFormat is a built-in JavaScript API for formatting dates according to a locale and a set of options. It supports regional conventions, timezones, date styles, time styles, and individual date components.
Format a Date for a Specific Locale
Format a Date in a Specific Timezone
The timezone option changes how the same instant is displayed. In this example, 10:30 UTC is 16:00 in India, which uses UTC+05:30.
Choose 12-Hour or 24-Hour Time
Use hour12: true for a 12-hour clock or hour12: false for a 24-hour clock. The final display may still reflect locale-specific conventions.
Format Individual Date Components
Remember: Intl.DateTimeFormat uses formatting options rather than custom tokens such as YYYY-MM-DD. If you need token-based patterns, use a formatter that explicitly supports those tokens or build the output from date components.
Custom JavaScript Date Formatting
Sometimes you need an exact output such as YYYY-MM-DD HH:mm:ss for logs, exports, or a particular application field. JavaScript does not provide a universal built-in token parser for patterns such as YYYY, MM, and DD, but you can construct a format using date components.
Example: Format a Date as YYYY-MM-DD
The numeric month in the Date constructor is zero-based. That is why October is passed as 9 in this example.
Example: Format a Local Date and Time
This function uses the computer's local timezone. For UTC output, use methods such as getUTCFullYear(), getUTCMonth(), getUTCDate(), and getUTCHours() instead.
Example: Convert Unix Seconds to a JavaScript Date
JavaScript's Date constructor expects a timestamp in milliseconds. Multiplying Unix seconds by 1,000 converts them to the required unit.
JavaScript Date Formatting Reference
The following table summarizes common methods and options for formatting dates. The methods belong to the JavaScript Date object, while the options are used with Intl.DateTimeFormat.
| Method or option | Purpose | Example |
|---|---|---|
toISOString() |
Returns an ISO date-time string in UTC. | 2026-10-15T10:30:00.000Z |
toUTCString() |
Returns a readable UTC date string. | Thu, 15 Oct 2026 10:30:00 GMT |
toLocaleDateString() |
Formats the date according to a locale. | date.toLocaleDateString("en-GB") |
toLocaleTimeString() |
Formats the time according to a locale. | date.toLocaleTimeString("en-US") |
toLocaleString() |
Formats the date and time according to locale settings. | date.toLocaleString("en-IN") |
getTime() |
Returns milliseconds since the Unix epoch. | date.getTime() |
dateStyle: "short" |
Uses a compact localized date style. | 10/15/26 in a typical US locale |
dateStyle: "long" |
Uses a localized long date style. | October 15, 2026 in en-US |
timeStyle: "short" |
Displays a localized time with limited detail. | 10:30 AM in a typical US locale |
timeZone: "UTC" |
Formats the date and time in UTC. | 10:30 AM for the sample instant |
hour12: false |
Requests 24-hour time formatting. | 16:00 |
Output can vary: Locale-sensitive methods may use different separators, punctuation, spacing, and localized names depending on the runtime's internationalization data. Avoid comparing localized output as if it were a fixed machine-readable string.
JavaScript Date Format Tokens Explained
Token patterns are common in date-formatting libraries, but they are not universal JavaScript syntax. If your converter supports custom tokens, use its documented token rules. The table below shows a common token convention for reference.
| Token | Meaning | Example |
|---|---|---|
YYYY |
Four-digit year | 2026 |
YY |
Two-digit year | 26 |
MM |
Two-digit month | 10 |
MMM |
Abbreviated month name | Oct |
MMMM |
Full month name | October |
DD |
Two-digit day of month in common token conventions | 15 |
ddd |
Abbreviated weekday name in common token conventions | Thu |
dddd |
Full weekday name in common token conventions | Thursday |
HH |
Two-digit hour in 24-hour time | 16 |
hh |
Two-digit hour in 12-hour time | 04 |
mm |
Two-digit minutes | 30 |
ss |
Two-digit seconds | 45 |
SSS |
Milliseconds in many token-based libraries | 123 |
A |
Uppercase AM/PM marker in some libraries | PM |
Z |
Timezone offset token in some libraries | +05:30 |
Token warning: Tokens differ between libraries. For example, uppercase MM commonly means month, while lowercase mm means minutes. Some libraries use DD for day of month, while others use different token conventions. Confirm the syntax supported by your formatter before using a pattern in production.
UTC, Local Time, and Timezone Formatting
Timezone handling is one of the most important parts of date formatting. A JavaScript Date represents a specific instant as milliseconds from the Unix epoch. It does not retain the original timezone label or the local date-time string used to create it.
UTC
UTC is a global reference for time. Use UTC formatting when you need a consistent representation independent of the user's location.
ISO output from this method is always expressed in UTC and ends with Z.
Local Time
Local date methods use the environment's local timezone. The output can differ between a developer's computer, a user's browser, and a server.
Use local methods when the intended display should follow the device's local timezone.
Named Timezones
Intl.DateTimeFormat can format an instant in a named timezone, such as Asia/Kolkata or America/New_York.
Timezone Offsets
An offset such as +05:30 describes the difference from UTC at a particular date and time. The offset for a named timezone can change due to daylight-saving rules.
Use a named timezone for region-specific rules rather than assuming a fixed offset will always apply.
How to Avoid Timezone Errors
- Include
Zor an explicit offset when an ISO date-time represents a specific instant. - Use
toISOString()when you need standardized UTC output. - Choose a named timezone when displaying dates for a specific region.
- Do not assume a server and browser use the same local timezone.
- Remember that date-only values may represent calendar dates rather than exact moments.
- Test dates near midnight and daylight-saving transitions when your application supports multiple regions.
JavaScript Date Formatter vs. Timestamp Converter
A date formatter changes how a date is displayed, while a timestamp converter focuses on translating between timestamp values and human-readable dates. Some tools combine both functions.
| Feature | JavaScript Date Formatter | Timestamp Converter |
|---|---|---|
| Primary purpose | Formats dates and times for display. | Converts epoch timestamps into dates and times, or vice versa. |
| Typical input | Date objects, ISO strings, or other supported date inputs. | Unix timestamps in seconds or milliseconds. |
| Locale support | Often supports locale-aware date display. | May provide standard date output with optional locale settings. |
| Custom formatting | May support localized options or custom patterns. | Usually focuses on timestamp conversion and standard formats. |
| Best use | Preparing dates for interfaces, reports, and applications. | Inspecting epoch values from logs, APIs, and databases. |
Common JavaScript Date Formatting Errors
Date formatting problems often come from invalid input, mismatched timestamp units, timezone assumptions, or differences between regional date conventions.
Using Seconds Instead of Milliseconds
JavaScript timestamps use milliseconds. Passing Unix seconds directly to the Date constructor usually produces a date near the beginning of 1970.
Multiply Unix seconds by 1,000 before constructing the date.
Invalid Date Input
Unrecognized strings can produce an invalid Date object. Formatting an invalid date may return Invalid Date or cause methods such as toISOString() to throw a RangeError.
Incorrect Month Index
JavaScript's numeric date constructor uses zero-based months. January is 0 and December is 11.
This creates a local date for October 15, 2026, not September 15.
Unexpected Timezone Shift
A date can display a different hour or calendar day when converted between UTC and local time.
Compare the UTC output with the intended local or named timezone before treating the difference as an error.
Ambiguous Date Strings
Strings such as 10/11/2026 can be interpreted differently across regions and environments.
Fix: Prefer a standard ISO string with an explicit timezone when representing an exact moment.
Confusing Formatting Tokens
Custom token conventions are not built into the JavaScript Date object, and different libraries can use different tokens.
Fix: Check the formatter's syntax or use Intl.DateTimeFormat with supported options.
Common Uses of a JavaScript Date Formatter
Date formatting is necessary anywhere an application needs to display, exchange, or record time-related information consistently.
Web Applications
Display dates for profiles, activity feeds, dashboards, user accounts, and administrative panels.
REST APIs and JSON
Standardize date-time values for requests, responses, API tests, and integration workflows.
Application Logs
Format timestamps consistently when investigating errors, comparing events, or tracing application behavior.
Scheduling and Calendars
Display appointments, event times, deadlines, and calendar dates in the appropriate timezone.
Databases and Exports
Prepare date values for data exports, reports, imports, and machine-readable storage formats.
International Websites
Present dates using regional conventions, localized month names, and 12-hour or 24-hour time.
JavaScript Date Formatting Best Practices
Consistent date handling helps prevent incorrect displays, confusing timezone conversions, and unreliable data comparisons.
- Use ISO date-time strings for data exchange. Include an explicit timezone when the value represents a specific instant.
- Use UTC for standardized timestamps. Methods such as
toISOString()provide predictable machine-readable output. - Use Intl.DateTimeFormat for localized display. It supports locale and timezone options without requiring custom formatting logic for every region.
- Validate input before formatting. Check
date.getTime()withNumber.isNaN()to detect invalid date objects. - Keep seconds and milliseconds distinct. JavaScript's timestamp unit is milliseconds, while many Unix timestamp sources use seconds.
- Avoid ambiguous date strings. Prefer standard date representations instead of relying on environment-specific parsing behavior.
- Test timezone-sensitive dates. Verify behavior around midnight, timezone changes, and daylight-saving transitions where relevant.
- Separate calendar dates from timestamps. A birthday or due date may represent a calendar day rather than a moment that should shift across timezones.
Frequently Asked Questions
What is a JavaScript date formatter?
A JavaScript date formatter converts date values into a chosen display format. It can produce ISO strings, localized dates, readable date-time strings, UTC output, and other supported representations for applications and data workflows.
How do I format a date in JavaScript?
Use Intl.DateTimeFormat for locale-aware formatting, toISOString() for standardized UTC output, or date component methods to build a custom string. The best method depends on whether you need human-readable output or a machine-readable value.
How do I format a date as YYYY-MM-DD?
Use a date-formatting library that supports the required token pattern, or construct the string with getFullYear(), getMonth() + 1, and getDate(). Pad the month and day with leading zeros when needed.
What is Intl.DateTimeFormat?
Intl.DateTimeFormat is a built-in JavaScript API for locale-sensitive date and time formatting. It supports options for date styles, time styles, individual components, and named timezones.
How do I convert a Unix timestamp to a JavaScript date?
If the Unix timestamp is in seconds, multiply it by 1,000 before passing it to new Date(). For example, use new Date(unixSeconds * 1000). If the input is already in milliseconds, pass it directly.
What is the difference between UTC and local time?
UTC is a global reference time. Local time is based on the environment's timezone, while a named timezone such as Asia/Kolkata applies the rules for a particular region when formatting a date.
Why does JavaScript show a different date or time?
The input may be interpreted in UTC and then displayed in local time, or the formatter may use a different timezone. Check the input's timezone information and explicitly choose the intended output timezone.
Does JavaScript support custom date format tokens?
The built-in Date object does not provide a general token-based formatter for patterns such as YYYY-MM-DD. Use a compatible formatting library or construct the desired string manually. Token conventions vary between libraries.
What does toISOString() return?
toISOString() returns a standardized ISO date-time string in UTC, usually with millisecond precision and a trailing Z. For example, an appropriate date may produce 2026-10-15T10:30:00.000Z.
How do I display a date in 12-hour or 24-hour format?
Use Intl.DateTimeFormat with the hour12 option. Set hour12: true for 12-hour time or hour12: false for 24-hour time, and specify a timezone when consistent output is required.
How can I check whether a JavaScript date is valid?
Create the date and check whether Number.isNaN(date.getTime()) is true. An invalid date returns NaN from getTime(). Validate input before calling methods that require a valid date.
Are JavaScript timestamps measured in seconds or milliseconds?
JavaScript timestamps use milliseconds since January 1, 1970 UTC. Unix timestamps are often expressed in seconds, so check the input unit before converting or formatting a timestamp.
Can I format dates for different countries?
Yes. Use locale identifiers such as en-US, en-GB, or en-IN with Intl.DateTimeFormat. Locale settings control regional presentation, while the timezone option determines which timezone is used for the displayed date and time.
Can I use a JavaScript date formatter for API responses?
Yes. A formatter can help prepare consistent date strings for API responses and testing. ISO date-time strings are often a suitable choice for representing instants because they include a standardized date-time structure and can explicitly identify UTC or an offset.
Is a JavaScript date formatter useful for timezone conversion?
Yes, when the formatter supports timezone selection. JavaScript's Intl.DateTimeFormat can display the same date in UTC or a named timezone such as Asia/Kolkata or America/New_York.