I want to change a file's date to tomorrow 21:00. I used touch, but when I type ls -l the year of the file is displayed instead of the hour.

-rw-r--r-- 1 ABCD DEF   0 sept. 30  2014 test01
-r-xr-xr-x 1 ABCD DEF   15 sept. 29 09:26 test02

Here for example, we can clearly see "2014" but not "21:00". Strange fact, when I perform touch --date "1 hour ago" test01 it gets displayed correctly, but touch --date "+1 hour" test01 won't work. Also, editing the file with emacs and saving it will display the hour instead of the year.

Is that normal? How can I change this behaviour without using parameters in ls nor changing the computer's config? (this is for a challenge)

2 Answers 2


ls has two time display formats:

  • For timestamps from the past 6 months: month, day, hour, minute.
  • For other timestamps (in the future, or from more than 6 months ago): year, month, day.

The intent is to gain horizontal space and not overwhelm the user with information. Showing “from this year” is more obvious than showing the current year and letting the user notice that it is indeed the current year. The exact time of day rarely matters for very old files. Dates in the future are rare.

GNU ls has an option --full-time to show the full file time (year, month, day, hour, minute, seconds, nanoseconds, timezone offset) regardless of when that time is. You can tune the output format with the option --time-style.


Problem solved. The problem is that if the date is in the future, it will display the year instead of the hour.

Here's a simple example: touch file and l gives

-rw-r--r-- 1 ABCD DEF 0 sept. 29 12:01 file

whic is normal. No try to change the date to be 15 seconds in the future : touch --date "+15 seconds" file and immediately ls -l

-rw-r--r-- 1 ABCD DEF 0 sept. 29  2014 file

And after 15 seconds, the same ls -l gives

-rw-r--r-- 1 rius_b users 0 sept. 29 12:03 file

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .