unixts2time(1)

NAME
unixts2time - converts Unix timestamps to date/time strings

SYNOPSIS
unixts2time [-T time_format_template | - -template time_format_template]
[-H | - -human-readable]
[-s | - -seconds] [-m | - -milliseconds] [-u | - -microseconds] [-n | - -nanoseconds]
unix_timestamp [...]
unixts2time [-h | - -help]
unixts2time [-v | - -version]

DESCRIPTION
unixts2time converts Unix timestamps to date/time strings in the format %Y-%m-%d %H:%M:%S.SSSSSSSSS. A Unix timestamp is the time (nanoseconds, microseconds, milliseconds, or seconds) since the Unix Epoch, i.e. January 1, 1970, 00:00:00.000000000 UTC.
By default, the timestamp-granularity is auto-detected using the following heuristic:

•   Seconds (s): from 0 (1970-01-01 00:00:00) to 4999999999 = 5e9-1 (2128-06-11 08:53:19), and -4999999999 = -5e9 (1811-07-23 15:06:41) to -1 (1969-12-31 23:59:59);

•   Milliseconds (ms): from 5000000000 = 5e9 (1970-02-27 20:53:20.000) to 4999999999999 = 5e12-1 (2128-06-11 08:53:19.999) and -4999999999999 = -5e12-1 (1811-07-23 15:06:41.999) to -5000000000 = -5e9 (1969-11-04 03:06:40.000);

•   Microseconds (µs) from 5000000000000 = 5e12 (1970-02-27 20:53:20.000000) to 4999999999999999 = 5e15-1 (2128-06-11 08:53:19.999999) and -4999999999999999 = -5e15-1 (1811-07-23 15:06:41.999999) to -5000000000000 = -5e12 (1969-11-04 03:06:40.000000);

•   Nanoseconds (ns) from 5000000000000000 = 5e15 (1970-02-27 20:53:20.000000000) and -5000000000000000 = -5e15 (1969-11-04 03:06:40.000000000).
That is, unless using dates around 1969/1970, ancient past, or distant future, the auto-detection should work reasonably well. Optionally, the timestamp granularity can be specified explicitly.

ARGUMENTS
The following options are available:

unix_timestamp ...
    The Unix timestamps to be converted. If no Unix timestamp is provided, the current system time is used. The timestamp may be provided as float or integer. For integers, the numbers can have a prefix 0x for hexadecimal (base 16), or 0 for octal (base 8). Otherwise, the number is interpreted as decimal (base 10).

-T time_format_template | - -template time_format_template
    Sets the template for printing the date/time strings. Default is ""%Y-%m-%d %H:%M:%S". The formatting is according to strftime(). See strftime(3) for details.

-H | - -human-readable
    Provide the output in human-readable form. Default: off.

-s | - -seconds
    The Unix timestamp is given in seconds. Default is auto-detection (see above).

-m | - -milliseconds
    The Unix timestamp is given in milliseconds. Default is auto-detection (see above).

-u | - -microseconds
    The Unix timestamp is given in microseconds. Default is auto-detection (see above).

-n | - -nanoseconds
    The Unix timestamp is given in nanoseconds. Default is auto-detection (see above).

-h | - -help
    Prints the program's command-line parameters and exits.

-v | - -version
    Prints the program version and exits.

EXIT STATUS
The unixts2time tool exits with 0 on success, and >0 in case of an error.

EXAMPLES

unixts2time

unixts2time --human-readable

unixts2time --human-readable --seconds 1773744755

unixts2time --human-readable --seconds -- -1000000

unixts2time --human-readable --milliseconds -- -442460258000

unixts2time --human-readable --seconds 1773736279

unixts2time --seconds 1 1000 1000000 1000000000 2000000000

unixts2time -s 1773736279

unixts2time --milliseconds 212847000000

unixts2time -H 212847008123456789

unixts2time 0x179cb2ae8af3dd89

unixts2time -H 0x179cb2ae8af3dd89

unixts2time -s 212847123.123

unixts2time -T "%x %X" -s 2096218885000000000

unixts2time -T "%b %d %H:%M:%S %Y %Z" 1773736279

unixts2time -T "%b %d %H:%M:%S %Y %Z" 1784186916836355733

unixts2time -T "%x %X" 1784186916836355733

unixts2time --version

unixts2time --help

SEE ALSO
strftime(3) time2unixts(1)

NOTES
This program is part of System-Tools. The latest version of System-Tools can be found on the System-Tools Homepage at System-Tools Homepage: https://www.nntb.no/~dreibh/system-tools/.

AUTHORS
Thomas Dreibholz, Homepage: https://www.nntb.no/~dreibh