Bash 5.0 adds $EPOCHSECONDS and $EPOCHREALTIME. The latter expands, each time it's referenced, to the number of seconds since the epoch with microsecond precision.
Experiment shows that the expansion always has exactly 6 digits after the decimal point. For example, if you typed "echo $EPOCHREALTIME" at just the right moment, it might print "1546925845.000000", not "1546925845.0" or "1546925845". I suggest documenting this behavior. It would be nice to be able to depend on the exact format, for example that ${EPOCHREALTIME/*./} is always exactly 6 digits long. (The number of digits before the decimal point won't change until 2286; I'm not too worried about that.) Proposed patch for doc/bashref.texi (please tweak this if needed): diff --git doc/bashref.texi doc/bashref.texi index d33cd571..6381c61a 100644 --- doc/bashref.texi +++ doc/bashref.texi @@ -5911,6 +5911,7 @@ Similar to @code{BASH_ENV}; used when the shell is invoked in @item EPOCHREALTIME Each time this parameter is referenced, it expands to the number of seconds since the Unix Epoch as a floating point value with micro-second granularity +as if formatted using a @samp{"%.6f"} @code{printf} format (see the documentation for the C library function @var{time} for the definition of Epoch). Assignments to @env{EPOCHREALTIME} are ignored. @@ -5918,7 +5919,7 @@ If @env{EPOCHREALTIME} is unset, it loses its special properties, even if it is subsequently reset. @item EPOCHSECONDS -Each time this parameter is referenced, it expands to the number of seconds +Each time this parameter is referenced, it expands to the integer number of seconds since the Unix Epoch (see the documentation for the C library function @var{time} for the definition of Epoch). Assignments to @env{EPOCHSECONDS} are ignored. -- Keith Thompson