str = FormatTime(sFormat,nTimeTimesMillion,bRoundMinutes)
This macro function converts the time nTimeTimesMillion into a string using the format sFormat.
Supply nTimeTimesMillion as the portion of a day expressed in millionths of a day (one unit is 0.0864 seconds). This function formats the supplied time; it does not choose a date or a reference time for an astronomical calculation.
Set bRoundMinutes to true when displaying hours and minutes to round to the nearest minute. Set it to false when displaying seconds to round to the nearest second.
Rounding is implemented by adding 30 seconds when bRoundMinutes is true, or half a second when it is false, before applying sFormat. The format controls which parts of the adjusted time are displayed. If seconds are included while bRoundMinutes is true, the displayed time is shifted forward by 30 seconds; the seconds are not set to zero. Rounding past midnight displays a time at the start of the next day.
sNoon = FormatTime('hh:nn', 500000, true) // 12:00
sSixPM = FormatTime('hh:nn', 750000, true) // 18:00
sSixPM = FormatTime('h:nn am/pm', 750000, true) // 6:00 pm
For a list of the allowed values of sFormat, see the topic on time formatting.
To include text whose letters you do not wish to have interpreted, such as "Printed on:", include that text in double quotes within the format string.
See also: FormatDate.
Topic 177650, last updated on 09-Oct-2026