Using Discord Timestamps in Bots, Embeds & Webhooks
The <t:UNIX:FORMAT> markup isn't limited to messages you type by hand — the exact same syntax works from bot code, embed fields, and webhook payloads.
Same syntax, any source
Discord's client doesn't distinguish between a timestamp a person typed and one a bot generated — both are just text matching the <t:UNIX:FORMAT> pattern, and both render identically. That means anywhere your bot sends text — a reply, a scheduled announcement, an embed field, a webhook payload — you can drop in a correctly formatted timestamp and it will render live, in each reader's own timezone, with no extra work on Discord's end.
Generating Unix seconds in code
You need the target moment as whole seconds since the Unix epoch (10 digits). Whatever language your bot is written in, whole seconds are required — sending milliseconds (13 digits) will break Discord's parser. Debugging a value your code already produced? Paste it into the Unix timestamp converter to see the date it represents before you ship it.
JavaScript / TypeScript (Discord.js v14)
import { Client, GatewayIntentBits, time, TimestampStyles } from 'discord.js';
// Method 1: Using template strings
const unixSeconds = Math.floor(Date.now() / 1000);
const timestampMarkup = `<t:${unixSeconds}:R>`; // e.g. "in 5 minutes"
// Method 2: Using discord.js built-in time() helper
const eventDate = new Date(Date.now() + 3600 * 1000);
const formatted = time(eventDate, TimestampStyles.RelativeTime);
await channel.send(`Event starts ${formatted}!`);Python (discord.py / Disnake / Nextcord)
import time
from datetime import datetime, timezone
import discord
from discord.ext import commands
# Method 1: Direct Unix timestamp with f-strings
unix_now = int(time.time())
timestamp_markup = f"<t:{unix_now}:R>"
# Method 2: Using discord.utils.format_dt helper
future_dt = datetime(2026, 12, 31, 20, 0, tzinfo=timezone.utc)
formatted = discord.utils.format_dt(future_dt, style="F")
@bot.command()
async def raid(ctx):
await ctx.send(f"Next raid begins {formatted} ({discord.utils.format_dt(future_dt, 'R')})")Discord Webhook JSON Payload
{
"content": "📢 Server Maintenance Notice",
"embeds": [
{
"title": "Scheduled Patch Maintenance",
"description": "Servers will be offline starting <t:1735689600:F> (<t:1735689600:R>).",
"fields": [
{
"name": "Expected Return",
"value": "<t:1735696800:t> local time",
"inline": true
}
],
"color": 5793266
}
]
}Timestamps inside embeds
Discord embeds have their own dedicated timestamp field (shown as a small date next to the footer), which is separate from putting <t:UNIX:FORMAT> markup inside an embed's description or a field's value. You can use either independently, or both together — the dedicated footer timestamp for "when this embed was generated," and inline timestamp markup within the body for something the embed is actually about, like an event start time.
Free HTTP REST API
Building an external service, GitHub Action, or CI/CD script that needs to generate Discord timestamp markup via HTTP? Check out our keyless Developer Portal & API with OpenAPI specs and live sandbox testing.
Further reading
For a full cheat sheet of all seven format letters (t, T, d, D, f, F, R), see the Discord timestamp cheat sheet. If a generated timestamp is rendering as raw text, check why a Discord timestamp might not be working. Need the creation time of amessage.id, user.id, or any other Discord object instead of a value your own code produced? See the Discord snowflake decoder — a snowflake ID isn't a plain Unix timestamp, so it needs a different calculation.