Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

While reading about Linux I got the following:

touch provides several options, but here is one of interest:

The -t option allows you to set the date and time stamp of the file. To set the time stamp to a specific time:

$ touch -t 03201600 myfile

This sets the file, myfile's, time stamp to 4 p.m., March 20th (03 20 1600).

Here, I am not getting the logic behind 03201600 --> 4pm, March 20th.

share|improve this question
5  
That is not what is usually called a Unix timestamp (there's no Linux timestamp, just a Unix one). See stackoverflow.com/questions/20822821/… for more info Unix timestamps. –  muru Sep 4 at 17:20

4 Answers 4

up vote 13 down vote accepted

The output you posted explains the format by breaking apart the numbers as (03 20 1600):

03 - March
20 - 20th
1600 - 4:00 PM (24-hour clock, where 0000 is midnight)
share|improve this answer
    
is it that 1hr = 100 from 12:00 AM –  jazzz Sep 4 at 17:39

Welcome to Linux! You probably read that touch text you quoted in your question from a guide or a book.

In Linux, almost every command has a "manual" that explains its options. You can view the manual page of any command by executing man <command> on a Linux machine.

So, from the command man touch:

   -t STAMP
          use [[CC]YY]MMDDhhmm[.ss] instead of current time

So, your example:

-t 03201600

#Breaking it down:

-t    03     20     16      00
-t    MM     DD     hh      mm
-t   month   day   hours  minutes

So March 20th, 4pm (24-hour format).

If you don't have access to a Linux machine, you can view these man pages online from here: http://unixhelp.ed.ac.uk/CGI/man-cgi. The man page for the command touch is found here: http://unixhelp.ed.ac.uk/CGI/man-cgi?touch

share|improve this answer
    
thanx @Alaa Ali, I totally got it –  jazzz Sep 4 at 17:40

According to man touch:

   -t STAMP
          use [[CC]YY]MMDDhhmm[.ss] instead of current time

So, your timestamp can be translated to DD/MM hh:mm: 20/03 16:00.

share|improve this answer

A timestamp is the current time of an event that is recorded by a computer.

Timestamps are employed extensively within computers and over networks for various types of synchronization. For example, they are assigned to packets in some network protocols in order to facilitate the reassembly of the data (e.g., human speech) in the proper sequence by the receiving host (i.e., computer). Also, they are used by database management systems (DBMS) to determine the transaction order in the event of a system failure (e.g., a computer crash caused by a loss of electrical power or disk failure).

Timestamps are also routinely used to provide information about files, including when they were created and last accessed or modified. This information is included in the inode, which is a data structure on a file system on a Unix-like operating system that stores all the information about a file except its name and its actual data.

Another important application is events that are recorded in system log files. The timestamps in such files can be extremely useful for monitoring system security and for forensic purposes.

The time as recorded by timestamps can be measured in terms of the time of day or relative to some starting point. And it is measured with high precision in small fractions of a second.

The accuracy of the time is maintained through a variety of mechanisms, including the high-precision clocks built into computers and the network time protocol (NTP). NTP uses coordinated universal time (UTC) to synchronize computer clock times to a millisecond (and sometimes to a fraction of a millisecond) and uses UDP (user datagram protocol), one of the core Internet protocols, as its transport mechanism.Timestamp

Click here to convert

share|improve this answer
    
thanx @Mitch , one more question is it somewhat related to NTP(network time protocol)? –  jazzz Sep 4 at 17:42
1  
Yes it uses that to calculate time. –  Mitch Sep 4 at 17:44
    
Although in this case, touch doesn't actually use a Unix timestamp. –  IQAndreas Sep 6 at 4:16
1  
The OP's question is "What is a timestamp in Linux?" and I explained what timestamp is. –  Mitch Sep 6 at 5:11

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.