Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have read the man pages for date command, but there is no option for converting unix time to string time. I found some websites telling this:

date -d @1343715322

there is no option like @ in the man and info pages. Can someone explain it?

share|improve this question
    
What kind of date implementation you have? @ is specific for GNU date. –  manatwork Jul 31 '12 at 6:43
    
My manpage for GNU date also doesn't describe @ but still uses it in an example. Yet I don't understand your question. @ seems to be the only way to do this with date so where's the problem? –  scai Jul 31 '12 at 6:49
add comment

2 Answers 2

up vote 2 down vote accepted

It's in the GNU date manual: http://www.gnu.org/software/coreutils/manual/coreutils.html#Seconds-since-the-Epoch. The same explanation is in the coreutils info pages.

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.

Internally, computer times are represented as a count of seconds since an epoch—a well-defined point of time. On GNU and POSIX systems, the epoch is 1970-01-01 00:00:00 utc, so ‘@0’ represents this time, ‘@1’ represents 1970-01-01 00:00:01 utc, and so forth. GNU and most other POSIX-compliant systems support such times as an extension to POSIX, using negative counts, so that ‘@-1’ represents 1969-12-31 23:59:59 utc.

Traditional Unix systems count seconds with 32-bit two's-complement integers and can represent times from 1901-12-13 20:45:52 through 2038-01-19 03:14:07 utc. More modern systems use 64-bit counts of seconds with nanosecond subcounts, and can represent all the times in the known lifetime of the universe to a resolution of 1 nanosecond.

On most hosts, these counts ignore the presence of leap seconds. For example, on most hosts ‘@915148799’ represents 1998-12-31 23:59:59 utc, ‘@915148800’ represents 1999-01-01 00:00:00 utc, and there is no way to represent the intervening leap second 1998-12-31 23:59:60 utc.

share|improve this answer
add comment

You usually won't find details like this in the man pages.

Check the info date, you will find this in the "Date input formats" section.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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