K
Docs
API Reference→Pieces→Read a Duration
⏱️

Read a Duration

clock.durationThe ClocktowerTime

Reads a length of time someone typed — 90s, 10m, 1h30m, 2 days, 1:30 — and gives you numbers to work with: {{duration.seconds}}, {{duration.minutes}}, words like “1 hour and 30 minutes”, and {{duration.at}}, the moment it lands if it started now. Invalid means it wasn't a length of time.

When to use this
  • →Months and years aren't a fixed length, so they're Invalid — use days or weeks

On the canvas

This is what Read a Duration looks like when you place it on your flow. Each field below is something you configure in the inspector panel.

⏱️
Read a Duration
clock.duration
Time
textrequired
e.g. {{input.options.duration}}
unit
select…
asrequired
duration
valid
invalid

Config fields

FieldTypeReqWhat it does
text
e.g. {{input.options.duration}}
textyesRead this ⏱️
unitselect—A plain number means… ⏱️
as
duration
textyesSave it as ✨

Sparks this piece adds

After this piece runs, these values are available as sparks in every node downstream.

{{duration.ms}}numberThe length in milliseconds
{{duration.seconds}}numberThe length in seconds
{{duration.minutes}}numberThe length in minutes
{{duration.text}}stringIn words: 1 hour and 30 minutes
{{duration.short}}stringShort: 1h 30m
{{duration.at}}numberWhen it lands if it started now, as a Unix time
{{duration.relative}}stringA live Discord countdown to that

Output ports

valid{{duration.text}} reads it back in words
invalidThat wasn't a length of time — ask again
📐

In TypeScript, this would be…

Not something you need to write — just a look at what Kitcord does for you.

TypeScript
const ms = parseDuration("1h30m"); // 5_400_000, or null → Huh? ✗
const minutes = Math.round(ms / 60_000); // {{duration.minutes}} = 90
const at = Math.floor((Date.now() + ms) / 1000); // {{duration.at}}