For the complete documentation index, see llms.txt. This page is also available as Markdown.

Clock

Display a clock adjusted to your preferred timezone.

Shows the current time of the timezone you pick. Write the format yourself, for example %H:%M for 19:35.

Availability: every bot, no API key. Only the update cadence differs: every 10 minutes on the public bot, every 5 minutes on a legacy premium, custom or self-hosted bot. See Configuration.

Clock options
The two options of the Clock counter, with the Live preview underneath

Options

Option
What it does
Notes

Timezone

The timezone the time is read in.

Pick one of the presets, which you can search. They carry friendly labels, such as Madrid for Europe/Madrid. You cannot type one that is missing: use a nested counter that returns an identifier such as Asia/Tokyo instead.

Format

The text the counter prints, with the placeholders below substituted.

Free text. The default is %f. Also takes a nested counter that returns a formatting string.

Display label

Renames the counter's chip in the editor.

Cosmetic. See Formatting counters.

Placeholders

Placeholder
What it does
Example

%H

Hour with leading zero, 24-hour (00-23)

19

%h

Hour without leading zero, 24-hour (0-23)

19

%I

Hour with leading zero, 12-hour (01-12)

07

%i

Hour without leading zero, 12-hour (1-12)

7

%M

Minute with leading zero (00-59)

35

%m

Minute without leading zero (0-59)

35

%S

Second with leading zero (00-59)

00

%s

Second without leading zero (0-59)

0

%p

am/pm (lowercase)

pm

%P

AM/PM (uppercase)

PM

%f

Default locale-based formatting

7:35 PM

The table shows 19:35 with the en-US locale. %f prints the hour and the minute, nothing else. Format prints the rest as you type it, and an empty one falls back to %f. The placeholders are case-sensitive, and Date and Countdown have their own sets.

What it returns

Text, never a number, even when the format is only digits. A voice or category channel name still has to end up at least 2 characters long; see Channel settings.

Formatting

Only Override default locale matters here: it decides what %f looks like, how %p and %P are worded, and which digits the time is written in. Without an override the counter follows Server settings. A locale with non-Latin digits breaks the four placeholders without a leading zero: ar-EG writes %H as ١٩, and %h, %i, %m and %s print NaN, so use %H, %I, %M and %S with such a locale. See Formatting counters.

Refresh and caching

The time is rounded to the nearest 5 minutes, so %S always prints 00 and at 19:33 the clock already reads 19:35. The channel changes only on the update cycle, so on the public bot 19:30 can sit there until 19:40. See How counters update.

Examples

Timezone Europe/Madrid, Format 🕒 %H:%M gives 🕒 19:35. For a 12-hour clock, %i:%M %P gives 7:35 PM.

A voice channel showing a 24-hour clock
A 24-hour clock in a voice channel name

A counter has one Timezone, so put two Clock counters in one template: Madrid {counter} | NY {counter}, set to Europe/Madrid and America/New_York, both with Format %H:%M. Output: Madrid 19:35 | NY 13:35.

A template with two Clock counters
Two Clock counters, one per timezone, in one template

A Date counter can sit in the same template, with its own Timezone.

A Date counter and a Clock counter in one template
A Date counter and a Clock counter in one template, with the rendered preview underneath

Errors

Clock has no fallback. When it fails the bot renames the channel to ERROR!, translated into the server's language, and it does not put the old name back. More in Troubleshooting.

Message
What to do

ERROR! in the channel name

Check the Timezone value and the Override default locale tag. The dashboard only reports An unknown error occurred. for these two.

The result for the channel name is less than 2 characters long.

Put some text around the counter.

Technical details
  • Evaluator: packages/services/src/DataSource/DataSourceEvaluator/evaluators/clock.ts. Nothing is cached; the time is recomputed on every template evaluation.

  • The rounding is Math.round(Date.now() / coeff) * coeff with coeff = 1000 * 60 * 5, so the rendered time can be up to 2 minutes 30 seconds ahead of real time.

  • %f is Intl.DateTimeFormat(locale, { hour: "numeric", minute: "numeric", timeZone }). %H, %M and %S come from formatToParts with hour12: false; %I, %p and %P from a second formatter with hour12: true.

  • %h, %i, %m and %s are parseInt() of the padded part, which is why a locale with non-Latin digits turns them into NaN.

  • With no Timezone picked, timeZone is undefined and Intl uses the host's timezone. The official containers run in UTC.

  • Locale resolution: the counter's override, else the server's, and en-US when the tag is shorter than 2 characters.

  • An invalid timezone identifier or locale tag makes Intl.DateTimeFormat throw a RangeError. It is not a KnownError, so the dashboard falls back to An unknown error occurred.

  • Each top-level counter in a template has a 60 second timeout (EVALUATION_TIMEOUT), covering its nested counters too. The result is cut to 99 characters for voice and category names, 1023 for text and announcement topics, and a name under 2 characters throws EVALUATION_RESULT_FOR_CHANNEL_NAME_IS_LESS_THAN_2_CHARACTERS.

  • On a failed evaluation the bot writes jobs.updateChannels.computeError (ERROR!) into the channel and stores the message as the channel's LastTemplateComputeError.

  • The Update channels job runs on cron 0 */5 * * * * when DISCORD_BOT_INSTANCE_IS_PREMIUM is true, and on 0 */10 * * * * when it is false. The shipped .env.example sets it to true. No other environment variable affects Clock.

  • The timezone list is apps/frontend/src/lib/timezones.ts (109 entries); the combobox only accepts entries from it.

  • There is no live preview when Format is empty or when a counter fills it; the whole template has to be previewed instead.

Last updated