Repository navigation
BLL Time
Method reference · date · number · Examples
time formats an elapsed duration, not a clock time or calendar date.
It returns text. Use date for a time of day.
time(format, milliseconds)
time(format, null, seconds)
time(format, milliseconds, seconds)When both inputs are supplied, seconds are added to milliseconds. The
supported text form is, for example, {[ time("H:mm:ss", 90061000) ]};
an expression-only card takes time("H:mm:ss", 90061000) without {[ ]}.
With a duration of 90061023 milliseconds (1 day, 1 hour, 1 minute,
1 second and 23 milliseconds):
| Code | Meaning | Output |
|---|---|---|
D, DD, DDD, DDDD, DDDDD
|
Total whole days, padded to at least 1–5 characters |
1, 01, 001, 0001, 00001
|
H, HH, HHH, HHHH, HHHHH
|
Total whole hours, padded to at least 1–5 characters |
25, 25, 025, 0025, 00025
|
h, hh
|
Hour component modulo 24 |
1, 01
|
M, MM, MMM, MMMM, MMMMM
|
Total whole minutes, padded to at least 1–5 characters |
1501, 1501, 1501, 1501, 01501
|
m, mm
|
Minute component modulo 60 |
1, 01
|
S, SS, SSS, SSSS, SSSSS
|
Total whole seconds, padded to at least 1–5 characters |
90061 for each |
s, ss
|
Second component modulo 60 |
1, 01
|
F, FF, FFF, FFFF, FFFFF
|
Total milliseconds, padded to at least 1–5 characters |
90061023 for each |
f, ff, fff
|
Millisecond component, padded to at least 1–3 characters |
23, 23, 023
|
Uppercase and lowercase matter: H, M and S are totals, while h, m
and s are the remaining components. Uppercase F is total milliseconds;
lowercase f is the millisecond component. Padding is a minimum width, not a
maximum, so a value wider than the token is not truncated. Unlike date's f
codes, duration f codes pad the millisecond component rather than truncating
it.
These are bare expressions for an expression-only card. Wrap them in
{[ ... ]} inside supported text.
| Expression | Output | Why |
|---|---|---|
time("D:hh:mm:ss.fff", 90061023) |
1:01:01:01.023 |
Day plus hour, minute, second and millisecond components. |
time("H:mm:ss", 90061000) |
25:01:01 |
Total hours include the day. |
time("hh:mm:ss", 90061000) |
01:01:01 |
Hour component excludes the day. |
time("M", 90061023) |
1501 |
Total whole minutes. |
time("S", 90061023) |
90061 |
Total whole seconds. |
time("H:mm:ss", null, 90) |
0:01:30 |
Input in seconds. |
time("H:mm:ss", 30000, 90) |
0:02:00 |
30 seconds in milliseconds plus 90 seconds. |
time('D"d" hh"h" mm"m" ss"s"', 90061023) |
1d 01h 01m 01s |
Quoted literal labels. |
time("D", 1000000000) |
11 |
Whole days in the app settings example. |
Enter this in Execute BLL-expression (as Tag):
time("M", new Date("2023-07-03T16:45:12+01:00") - new Date("2023-07-03T15:15:12+00:00"))The number tag is 30: the card converts the text result, so parseInt is
not needed. Use the text tag when you need the formatted string. This is
adapted from a community example.
In the 4.2.3 source, the expression helper and Format time card use truthiness checks when forwarding duration inputs, so an explicit zero milliseconds or seconds value can be treated as missing. If no other nonzero duration is supplied, this can cause a missing-input error. Negative durations can also produce unintuitive components. Test zero and negative inputs in your installed version. For countdowns, consider checking whether the difference is positive before formatting it.
For event timestamps, stale readings, time differences and the current-hour fraction, see time calculations. For live reflected timer displays, see Device Capabilities and AVD.
Support development - If Better Logic Library is useful to you, you can support its
continued development through GitHub Sponsors,
Patreon,
PayPal, or
bunq.
Thank you!