I was reading through the man page of ls on UNIX, specifically OS X Mavericks. This got me intrigued:

If the modification time of the file is more than 6 months in the past or future, then the year of the last modification is displayed in place of the hour and minute fields.

Why would someone set the modification time to the future?

  • 3
    So that when you travel back/forwards in time the modification time is right. Or was right. Or will be right. – Andrew Nov 26 '13 at 23:57

It all depends on the point of reference. Maybe it's not the file that has a modification time in the future, maybe it's the user looking at the file who's living in the past?

Otherwise, filesystem can be used to store arbitrary data, and files can have arbitrary attributes (e.g. with xattr on OS X), so, maybe someone wants to store calendar-like data in the filesystem, and represent the events through the modification time attribute?

  • Hadn't thought about the calendar thing. Nice usage idea indeed. Thanks! – conradk Nov 26 '13 at 22:03
  • @conradk I think it's a pretty terrible usage idea (it's a filesystem, not a calendar, and doing that totally violates the Principle of Least Astonishment. It is frightfully clever though. Emphasis on the frightful :) – voretaq7 Nov 27 '13 at 22:20
  • 1
    But we're not talking about dates generally, yes they can be in the future but we are talking about the modification date which implies its a timestamp of when updated by the user. Only case I can think of if for writing tests that want to set it manually to test conditions in the code without inventing a time machine. – Michael Durrant Nov 27 '13 at 23:06
  • @voretaq7: I don't agree with this principle in this case. If it's prominently documented, I think that would be fine. And for personal usage, that would be even more fine since no one else would have to understand. A computer is just a tool. I use it to fix problems, not to respect principles. – conradkleinespel Nov 7 '14 at 12:18

Users can freely set the modification time of a file to any date (at least within a large range, often 1901 to 2038). A date in the future could be due to a user's whim or typing error. A date in the future could also be the result of filesystem corruption.

However, in virtually all concrete cases, a date in the future is the result of a clock set to the wrong date, either on the machine where the file was written or on the machine where you're looking at the file.

In particular, it's common to see files with today's date instead of the time on networks where files are shared with protocols such as NFS or Samba, but clocks aren't synchronized between machines. If a file's date is even one second in the future, it's displayed as being in the future.


In addition to cnst answer, having a file modification time in the future is something that can happen when a file is stored on a remote file server share through NFS or CIFS and the client and server clocks are not synchronized through NTP or one of them has the correct time but the wrong time zone.

Note also that this ls behavior is BSD / OS X specific and is breaking the POSIX standard. Most if not all other Unix ls implementations display the year instead of the time if the file modification time is, even slightly, in the future.

The BSD / OS X ls manual page which states

If the modification time of the file is more than 6 months in the past or future

would be less ambiguous if rephrased:

If the modification time of the file is more than 6 months in the past or is in the future

  • 2
    Actually the OS X and BSD behavior is correct per the POSIX standard (The date format is specified as "+%b %e %Y" if the file has not been modified in the last six months or if the modification date is in the future), and a timestamp of even 1 second in the future forces the year-format date be shown. You can check this yourself using touch -t on a BSD-derived system.) The man page just has some "questionable" grammar inherited from FreeBSD. – voretaq7 Nov 27 '13 at 22:32
  • As voretaq7 noted, the BSD behavior is the POSIX behavior. What system behaves differently (shows HH:MM for dates in the near future)? – Gilles 'SO- stop being evil' Nov 27 '13 at 23:35
  • @voretaq7 I stand corrected. I was fooled by the manual page and failed to check. Thanks for pointing out the mistake. Answer updated. – jlliagre Nov 28 '13 at 3:43
  • @Gilles No system hopefully. – jlliagre Nov 28 '13 at 3:44
  • @jlliagre I will be submitting a documentation patch for that man page the next free 5 minutes I have to fight with nroff formatting. (Apple will probably never pick it up, but hopefully it will make better grammatical sense in a future FreeBSD release :-) – voretaq7 Nov 30 '13 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.