The simplest and cleanest option is to use
date -ud "@$elapsed" "+Elapsed Time: %T"
$elapsed represents the time delta in seconds.
You can avoid forking the external
date process by sticking to shell built-ins . The
printf shell command has a
%(...)T date/time format specifier that is often overlooked:
TZ=UTC0 printf "Elapsed Time: %(%T)T\n" $elapsed
date -u set the timezone to UTC, which prevents any timezone/DST related ambiguity.
Since this question emphasizes formatting, these methods are much more convenient and far less error-prone than calculating date parts because you have the entire range of
date format options available to you - no math needed. They work well for intervals of up to 24 hours, and other than the sub-second precision, should work in Bash v4.2+ as well.
Suppose you wanted to add nanoseconds as well:
$ #wait or run process
$ date -ud "@$((SECONDS-start))" "+Elapsed Time: %H:%M:%S.%N"
Elapsed Time: 00:00:12.003247901
$ #Or, preferably
$ TZ=UTC0 printf "Elapsed Time: %(%H:%M:%S.%N)T\n" $((SECONDS-start))
Elapsed Time: 00:00:12.005056068
You can abstract out your time measurement with aliases to make things easier. For example, we can emulate the Oracle TIMING command like this:
alias timingstop='TZ=UTC0 printf "Elapsed Time: %(%T)T\n" $((SECONDS-start))'
$ sleep 2
Elapsed Time: 00:00:02
 For the
$SECONDS variable, see
man ksh | less +/SECONDS
printf time formats, see
man ksh | less +/date-format -j.9