Convert date and time

Working with dates and times may seem simple at first glance, but any developer, tester or data analyst who has dealt with international applications or backend logic knows the reality is far more complex. The world does not use a single format to display dates, nor is there one universal way to store a point in time. Depending on your target audience, country, time zone or even the software you use, you may encounter a wide variety of formats, representations and technical constraints.

To help ease this complexity, you can use the tool below, which allows you to switch between Unix timestamps (in seconds or milliseconds), human-readable date formats, and even custom layouts based on user-defined patterns.

One of the key concepts addressed by this tool is the Unix timestamp, also known as epoch time. This format is used worldwide to represent a moment in time in a standardised, timezone-independent manner. A Unix timestamp counts the number of seconds since 1 January 1970 at 00:00:00 UTC. For example, a timestamp like 1751796336 represents 6 July 2025 at 12:06:36 UTC. Because many systems operate on millisecond precision, for example JavaScript's Date.now(), the millisecond variant (x) is also supported.

While timestamps are efficient for computers, they're not exactly user-friendly. That's why they're often converted to a human-readable date and time notation, such as 2025-07-06 14:23:45. The way in which dates are written varies widely between countries, systems and standards. For instance, in the UK we'd typically write 06/07/2025 14:23, while in the United States it would be 07/06/2025 02:23 PM. There are also formal data exchange formats like ISO 8601 (2025-07-06T14:23:45Z) or RFC 2822 (Sun, 06 Jul 2025 14:23:45 GMT), which are widely used in APIs and email systems.

To make all of this manageable, the tool provides several pre-configured formats, including ISO (local or UTC), RFC, and locale-based formatting using Intl.DateTimeFormat. Of course, there's also a custom mode that lets you build your own format, for example DD/MM/YYYY HH:mm:ss would output 06/07/2025 14:23:45.

The tool includes both a formatter and a parser, which rely on so-called tokens. These tokens act as placeholders when formatting, and as recognisable input parts when parsing. Below is a table listing all supported tokens. It's worth noting that all tokens are available for formatting, but some such as MMMM for full month names are not yet supported for parsing.

TokenMeaningFormatterParser
YYYYFour-digit yearYesYes
YYLast two digits of yearYesYes
MMMMFull month nameYesNo
MMMAbbreviated month name (3 letters)YesNo
MMMonth with leading zero (01–12)YesYes
MMonth without leading zero (1–12)YesYes
DDDay of month with leading zero (01–31)YesYes
DDay of month without leading zeroYesYes
ddddFull weekday nameYesNo
dddAbbreviated weekday name (3 letters)YesNo
ddShort weekday name (2 letters)YesNo
dDay of week (1=Sunday)YesNo
HH24-hour format with leading zeroYesYes
H24-hour formatYesYes
hh12-hour format with leading zeroYesYes
h12-hour formatYesYes
kk1–24 hour format with leading zeroYesYes
k1–24 hour formatYesYes
mmMinutes with leading zeroYesYes
mMinutes without leading zeroYesYes
ssSeconds with leading zeroYesYes
sSeconds without leading zeroYesYes
SSSMilliseconds (3 digits)YesYes
AAM or PM (uppercase)YesYes
aam or pm (lowercase)YesYes
ZZTime zone offset without colon (e.g. +0200)YesYes
ZTime zone offset with colon (e.g. +02:00)YesYes
zTime zone name (like CET)YesNo
QQQFull quarter name (e.g. "2nd quarter")YesNo
QQQuarter in Q1–Q4YesNo
QQuarter as number (1–4)YesNo
XEpoch in secondsYesYes
xEpoch in millisecondsYesYes

One of the tool's key strengths is that it works both ways. If you input a timestamp, the date field will update automatically based on the selected format. Conversely, if you enter a date for example 06-07-2025 14:23:45 using the pattern DD-MM-YYYY HH:mm:ss, the corresponding timestamp is calculated immediately. This makes the tool extremely useful when testing date logic in frontend or backend code, debugging logs, or simply converting a date into a timestamp and vice versa.

Behind the scenes, the widget uses JavaScript's Date object, Intl.DateTimeFormat, and regular expressions to match tokens and extract values. User preferences are stored in localStorage, so your favourite configuration is remembered for future visits.

Whether you're new to web development or an experienced engineer, date and time logic is something you'll face in almost every project. This tool simplifies a notoriously tricky part of development and gives you the flexibility to work with dates in whichever format your application demands.

Link

Further reading

Widget made with staark