[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Decode unixtime



On 20100115_051059, T o n g wrote:
> Hi,
> 
> Which tool can help me decode the Unix time? E.g., strings like 
> 1257624539, 1258162046, 1257623988, 1257709563, etc. they are about 68 
> days ago.
> 
> Thanks
> 

date contains the standard time/date handling code, but it is
inconvenient to give it a ten digit Unix time number. Where are you
getting these numbers?  I suggest that you change the way you get the
numbers so that they are both human readable and parsable by simple
code. I like date +%Y%m%d_%H%M%S

This gives a string of 15 bytes that sorts to the same order as the UNIX 
time number and is visually understandable with only a little effort.
(It has no embedded spaces and is almost as compact as 10 digit Unix time.)

If the time of interest is the modification time of file, foo, the
command is

date +%Y%m%d_%H%M%S -r foo

For the mod time of foo in the UTC time zone use

date +%Y%m%d_%H%M%S -ur foo

See, man date

-- 
Paul E Condon           
pecondon@mesanetworks.net


Reply to: