2

GNU date and touch commands (and presumably others) use @date to define a date string as seconds since the epoch. For example:

$ TZ=UTC date -d@10
Thu Jan  1 00:00:10 UTC 1970

I was answering a question and wanted to point the OP to where this particular feature was documented but I can't find it. Neither man date not man touch explain it. The closest is this from the "Examples" section of the date man page:

   Convert seconds since the epoch (1970-01-01 UTC) to a date

          $ date --date='@2147483647'

The info page for date states that this was introduced in coreutils 5.3.0, but does not really explain it further either:

 Or if you do not mind depending on the `@' feature present since
 coreutils 5.3.0, you could shorten this to:

      date -d @946684800 +"%F %T %z"
      1999-12-31 19:00:00 -0500

So, where is @seconds documented? Where am I supposed to learn about it and where can I point someone who does not? Is that off-hand mention in man date really the best we have?

4

This is documented in Section 28.9, "Seconds since the Epoch" of the GNU Coreutils info page:

info Coreutils 'Seconds since the Epoch'

I am including the first paragraph here: The section reads:

If you precede a number with `@', it represents an internal time stamp as a count of seconds. The number can contain an internal decimal point (either .' or,'); any excess precision not supported by the internal representation is truncated toward minus infinity. Such a number cannot be combined with any other date item, as it specifies a complete time stamp.

  • Are you sure the capital Coreutils is needed? It isn't on my LMDE (which is basically Debian testing) and it shouldn't be since the "correct" name is coreutils and not Coreutils. I am afraid that it might not work on other systems unless its not capitalized. – terdon Sep 8 '14 at 15:31
  • @terdon I've tested on various machines; on them, info Coreutils always works, but info coreutils sometimes gives an unrelated page. Have you tried with GNU Coreutils 8.23? – vinc17 Sep 8 '14 at 15:37
  • @terdon The man pages still give the version with a lowercase c, though it no longer works. I've reported a bug: Debian bug 760861. So, let's see what the developers say. – vinc17 Sep 8 '14 at 15:58

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.