DEV Community

Quratulain Memon
Quratulain Memon

Posted on

"How Discord Timestamps Work — A Complete Guide"

How Discord Timestamps Work — A Complete Guide

If you've ever seen a message in Discord that says "3 hours ago" or "Tomorrow at 9:00 AM" and wondered how it stays accurate no matter who's reading it, the answer is a small piece of Markdown syntax that Discord added a few years ago: dynamic timestamps.

This post breaks down exactly how they work, why they're better than typing a date manually, and how to generate them without doing the math yourself.

The syntax

Discord renders a timestamp whenever it sees this pattern in a message:

<t:1721000000:R>
Enter fullscreen mode Exit fullscreen mode

Two parts matter here:

  • 1721000000 — a Unix timestamp (seconds since Jan 1, 1970 UTC)
  • R — a format flag that controls how it's displayed

Discord's client reads the Unix timestamp, converts it to the viewer's own local timezone, and renders it using the style you picked. That's the whole trick — the message itself never changes, but everyone sees a time that's correct for them.

The 7 format flags

Flag Style Example
t Short time 4:20 PM
T Long time 4:20:30 PM
d Short date 07/14/2026
D Long date July 14, 2026
f Short date/time July 14, 2026 4:20 PM
F Long date/time Monday, July 14, 2026 4:20 PM
R Relative 3 hours ago / in 2 days

R is by far the most commonly used, especially for event countdowns, since it automatically updates itself as time passes — no editing required.

Why not just type the date?

Two problems with hardcoding a date/time in a message:

  1. Timezones. "9 PM EST" means nothing useful to someone in Karachi or Tokyo without them doing the conversion in their head.
  2. Drift. A relative time like "in 3 hours" written as plain text is wrong the moment someone reads it an hour later. Discord's R flag recalculates it live, client-side, every time it's viewed.

Dynamic timestamps solve both, for free, using a format the client already understands.

Getting the Unix timestamp

This is the part that trips people up. You need the exact Unix timestamp for the date/time you want, in seconds (not milliseconds — that's a common bug, since JavaScript's Date.now() returns milliseconds by default).

In JavaScript:

const unixSeconds = Math.floor(Date.now() / 1000);
Enter fullscreen mode Exit fullscreen mode

Or for a specific future date:

const eventDate = new Date('2026-08-01T18:00:00Z');
const unixSeconds = Math.floor(eventDate.getTime() / 1000);
Enter fullscreen mode Exit fullscreen mode

Then wrap it: <t:${unixSeconds}:F>

A shortcut if you don't want to do the math

Since doing this manually for every event, deadline, or announcement gets tedious fast, I built a small free tool that generates all 7 formats at once from a date picker, with a live preview of how each one will actually render: discordtimestampgenerator.com. No signup, just pick a date and copy the format you need. It also has a Unix timestamp converter and a Snowflake ID decoder if you're working with Discord's API and need to pull a timestamp out of a message or user ID.

Bonus: timestamps hidden inside Snowflake IDs

Every Discord ID (message, user, channel, server) is a Snowflake — a 64-bit number that encodes a creation timestamp in its first 42 bits, offset from Discord's epoch (1420070400000, or Jan 1, 2015). That means you can extract when any message or account was created directly from its ID, without an API call:

const DISCORD_EPOCH = 1420070400000n;
function snowflakeToDate(snowflake) {
  const ms = (BigInt(snowflake) >> 22n) + DISCORD_EPOCH;
  return new Date(Number(ms));
}
Enter fullscreen mode Exit fullscreen mode

Useful for bot developers debugging account age checks, message ordering, or anti-spam logic.

That's really the whole system — one Markdown pattern, a Unix timestamp, and a format flag. Once you know the syntax, you'll probably never type a manual date in a Discord message again.

Top comments (0)