Current system time in hex

Revision history
Tags: linux bash

Get current system time as HEX string


# Get zero-padded hex string from date format
# Usage: f <format>
function f {
	printf %02X $(date +$1)

h=$(f %-H)
m=$(f %-M)
s=$(f %-S)

echo $h:$m:$s


$ date && timestring
Thu Mar 23 14:34:02 CET 2017

If you have any comments or feedback, please send me an e-mail. (stig at stigok dotcom).

Did you find any typos, incorrect information, or have something to add? Then please propose a change to this post.