Recent versions of bash
don't require call to the external program date
:
printf -v timestamp '%(%T)T'
%(...)T
uses the corresponding argument as a UNIX timestamp, and formats it according to the strftime
-style format between the parentheses. An argument of -1
corresponds to the current time, and when no ambiguity would occur can be omitted.