Skip to content
Date & Time time

$time[]

The function $time[] sets the timezone used by the date and time functions ($hour, $minute, $second, $date, $day, $month, $year, $creationDate, …) evaluated afterwards in the command.

Syntax

$time[timezone]

Parameters

Parameter Description
timezone Required - A TZ database timezone name (e.g., Europe/Paris, America/New_York).

Return Value

None (empty string). An error is raised if the timezone is empty or unknown.

Examples

Set the timezone

$time[Europe/Paris]
It is $hour:$minute:$second in Paris.

Date in a given timezone

$time[America/New_York]
📅 $date, hour: $hour

Notes

  • Used on its own ($time with no argument) the function is invalid; $time[] with an empty value raises Timezone is required.
  • Surrounding spaces in the timezone name are ignored; the name is otherwise case-sensitive (europe/paris is unknown). Without $time, date and time functions use UTC.
  • An unknown name raises Unknown TZ database timezone: <name>.
  • For the individual values, use $hour, $minute and $second. $getTimestamp is not affected by the timezone.
  • For a Unix timestamp, use $getTimestamp[].

Try it

Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.