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.
Token | Meaning | Formatter | Parser |
---|---|---|---|
YYYY | Four-digit year | Yes | Yes |
YY | Last two digits of year | Yes | Yes |
MMMM | Full month name | Yes | No |
MMM | Abbreviated month name (3 letters) | Yes | No |
MM | Month with leading zero (01–12) | Yes | Yes |
M | Month without leading zero (1–12) | Yes | Yes |
DD | Day of month with leading zero (01–31) | Yes | Yes |
D | Day of month without leading zero | Yes | Yes |
dddd | Full weekday name | Yes | No |
ddd | Abbreviated weekday name (3 letters) | Yes | No |
dd | Short weekday name (2 letters) | Yes | No |
d | Day of week (1=Sunday) | Yes | No |
HH | 24-hour format with leading zero | Yes | Yes |
H | 24-hour format | Yes | Yes |
hh | 12-hour format with leading zero | Yes | Yes |
h | 12-hour format | Yes | Yes |
kk | 1–24 hour format with leading zero | Yes | Yes |
k | 1–24 hour format | Yes | Yes |
mm | Minutes with leading zero | Yes | Yes |
m | Minutes without leading zero | Yes | Yes |
ss | Seconds with leading zero | Yes | Yes |
s | Seconds without leading zero | Yes | Yes |
SSS | Milliseconds (3 digits) | Yes | Yes |
A | AM or PM (uppercase) | Yes | Yes |
a | am or pm (lowercase) | Yes | Yes |
ZZ | Time zone offset without colon (e.g. +0200) | Yes | Yes |
Z | Time zone offset with colon (e.g. +02:00) | Yes | Yes |
z | Time zone name (like CET) | Yes | No |
QQQ | Full quarter name (e.g. "2nd quarter") | Yes | No |
QQ | Quarter in Q1–Q4 | Yes | No |
Q | Quarter as number (1–4) | Yes | No |
X | Epoch in seconds | Yes | Yes |
x | Epoch in milliseconds | Yes | Yes |
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.
LinkFurther reading
- Wikipedia: ISO 8601
- MDN: Date
- MDN: Intl.DateTimeFormat
- IETF: Date/Time Formats from RFC 7231, Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content
Widget made with staark