Index | Thread | Search

From:
Jan Stary <hans@stare.cz>
Subject:
mtime format in ls -l
To:
tech@openbsd.org
Date:
Fri, 16 Jan 2026 12:24:37 +0100

Download raw body.

Thread
The long format of ls -l is documented as follows:

     If the -g, -l, or -n options are given, the following information is
     displayed for each file: mode, number of links, owner (though not for
     -g), group, size in bytes, time of last modification (“mmm dd HH:MM”),
     and the pathname.

The mtime format only seems to be 'mmm dd HH:MM', as in 'Sep 15 13:08',
for files with mtime less than six months ago. For older files, it becomes
'mmm dd  yyyy', as in 'Feb 11  2025'. Indeed, the printtime() function
in bin/ls/print.c says

if (strftime(f_date, sizeof(f_date), f_sectime ? "%b %e %H:%M:%S %Y" :
    (ftime <= now - SIXMONTHS || ftime > now) ? "%b %e  %Y" :
    "%b %e %H:%M", tm) == 0)
	f_date[0] = '\0';

Below is a diff to the manpage saying so.
(Note the two spaces, quoted.)

Would it make more sense, instead, to display the YEAR instead of HH:MM
for files having the year of mtime other that the current year?

	Jan


--- ls.1.orig	Fri Jan 16 12:09:57 2026
+++ ls.1	Fri Jan 16 12:20:54 2026
@@ -282,7 +282,12 @@ owner (though not for
 group,
 size in bytes,
 time of last modification
-.Pq Dq mmm dd HH:MM ,
+.Po
+.Dq mmm dd HH:MM
+for files last modified within the last six months,
+.Dq "mmm dd  yyyy"
+otherwise
+.Pc
 and the pathname.
 In addition, for each directory whose contents are displayed, the first
 line displayed is the total number of blocks used by the files in the