Ubuntu: What is a timestamp in Linux?


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.


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)  


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


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.


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

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »