Discord lets you post a time that shows up in every reader's own timezone. You just need the Unix timestamp for that moment, in seconds.
The Discord syntax
| Style | Shows as |
|---|---|
t |
16:20 |
T |
16:20:30 |
d |
20/04/2021 |
D |
20 April 2021 |
f |
20 April 2021 16:20 |
F |
Tuesday, 20 April 2021 16:20 |
R |
2 months ago (updates live) |
Getting the timestamp
1. In code
- JavaScript:
Math.floor(Date.now() / 1000) - Python:
int(time.time()) - Terminal (macOS/Linux):
date +%s
2. HammerTime
Open-source and built for exactly this. Pick a date, copy the tag for the style you want.
3. A general epoch converter
Sites like epochconverter.com or unixtimestamp.com convert both ways, which helps when you need to read an existing timestamp too.
4. Your bot library
discord.js and discord.py both have helpers for formatting timestamps, so you can skip manual conversion in a bot.
5. A browser-based generator
Disclosure: I maintain one at ToolHub Discord-Timestamp-Generator It covers all 7 styles and runs client-side.
Two things that trip people up
- Discord expects seconds, but JavaScript's
Date.now()returns milliseconds. Divide by 1000 or your date lands in the year 50000-something. -
Ris the best style for events, since it becomes a live countdown.
Which method do you use? I'm curious whether most people script it or use a site.
Top comments (1)