Page 1 of 1

HowTo: Directory listing with ISO8601 date/time

PostPosted: Tue Mar 05, 2019 9:20 pm
by peter_b
This HowTo explains quickly how to get the full date/time information for a directory listing in the shell.

By default, "ls" on GNU/Linux (e.g. Debian, Ubuntu, etc) only gives a short view of date and time for files and folders:
Normal listing with default formatting.

When a timestamp is further in the past, the time is not displayed at all anymore. Just the month and the year.
This is absolutely insufficient for a directory listing for fixity purposes.

Gladly, the developers already provided the parameter "--time-style" to control the date/time formatting :D
In order to provide a standard and machine-readable timestamp output, the following options for time-style are good:
  • long-iso:
    Example = 2018-07-23 11:35
  • full-iso:
    Example = 2018-07-23 11:35:55.980039161 +0200

Both provide an ISO8601-formatted timestamp, but in different forms:
The first one, "long-iso" has minute-exact accuracy, whereas the "full-iso" shows the full time information including timezone data: "+0200"

So with the following command, your directory listing will be proper:
Code: Select all
$ ls -la --time-style=full-iso

Example output:
Full ISO8601 formatted timestamp (including timezone offset)

Have fun! :D