Formatting Strings for Clock Time Display

These expressions may be used to control how time is displayed using the format attribute of the clock element:

ExpressionOutput
hThe hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)
hhThe hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)
HThe hour without a leading zero (0 to 23, even with AM/PM display)
HHThe hour with a leading zero (00 to 23, even with AM/PM display)
mThe minute without a leading zero (0 to 59)
mmThe minute with a leading zero (00 to 59)
sThe whole second, without any leading zero (0 to 59)
ssThe whole second, with a leading zero where applicable (00 to 59)
zThe fractional part of the second, to go after a decimal point, without trailing zeroes (0 to 999). Thus "s.z" reports the seconds to full available (millisecond) precision without trailing zeroes.
zzzThe fractional part of the second, to millisecond precision, including trailing zeroes where applicable (000 to 999).
AP or AUse AM/PM display.
ap or aUse am/pm display.
tThe timezone (for example "CEST")

Any non-empty sequence of characters enclosed in single quotes will be included verbatim in the output string (stripped of the quotes), even if it contains formatting characters. Two consecutive single quotes ("''") are replaced by a single quote in the output. All other characters in the format string are included verbatim in the output string.

Formats without separators (e.g. "ddMM") are supported but must be used with care, as the resulting strings aren't always reliably readable (e.g. if "dM" produces "212" it could mean either the 2nd of December or the 21st of February).

Example format strings assuming the time is 14:13:09.042 and the system locale is en_US

FormatResult
hh:mm:ss.zzz14:13:09.042
h:m:s ap2:13:9 pm
H:m:s a14:13:9 pm

If the time is invalid, an empty string will be returned. If format is empty, the default format "hh:mm:ss" is used.