Time calculations
The Dates and times page covers how Rhyme stores times. This page covers the timefn set — the actions that read and format times, get the current time, and check the user’s timezone.
Every timefn action returns a value — capture the result with $result = , just like the math and date actions.
Getting the current time
$now = time-now// current time as "HH:MM:SS", e.g. "14:30:45"time-now takes no arguments — it always reads the system clock.
Reading parts of a time
| Action | What it does | Example |
|---|---|---|
get-hour | Hour, 0–23 | $h = get-hour from $timestamp |
get-minute | Minute, 0–59 | $m = get-minute from $timestamp |
get-second | Second, 0–59 | $s = get-second from $timestamp |
get-time | All three combined, as HH:MM:SS | $t = get-time from $timestamp |
Each takes a timestamp value connected with from:
$sample = "2025-11-14T14:30:45"$hour = get-hour from $sample$minute = get-minute from $sample$second = get-second from $sample// 14, 30, 45
$hms = get-time from $sample// "14:30:45"get-time always returns the fixed HH:MM:SS format. For any other layout, use format-time.
Formatting a time
format-time takes a template, the same way format-date does. Useful tokens: HH/H for 24-hour, hh/h for 12-hour, mm for minutes, ss for seconds, and A/a for AM/PM:
$sample = "2025-11-14T14:30:45"$formatted = format-time $sample as "h:mm A"// "2:30 PM"
$formatted2 = format-time $sample as "HH:mm:ss"// "14:30:45"Timezone and network time
get-browser-timezone reads the user’s device timezone. It returns an object rather than a single value, so pull out the field you need:
$timezone = get-browser-timezone.text "Your timezone: {$timezone.timezone}"get-internet-time fetches the current time from a network time service, for situations where you don’t trust the device clock. It also returns an object, and can fail if the network is unavailable:
$internet-time = get-internet-timeCommon mistakes
| Mistake | Fix |
|---|---|
Calling get-time/get-hour/etc. without from | The connecting word is required: get-hour from $timestamp |
Expecting get-browser-timezone/get-internet-time to return plain text | They return an object — access a field, e.g. $timezone.timezone |
Reaching for format-time when the default HH:MM:SS is fine | Use the simpler get-time from $timestamp instead |
Complete example: time-based greeting and log line
$sample = "2026-08-22T09:15:00"$current-hour = get-hour from $sample
if $current-hour < 12: .text "Good morning!" -bold:else .text "Good afternoon!" -bold:end
$log-time = format-time $sample as "HH:mm:ss".text "[{$log-time}] Task started"