Linux 中的时间戳是什么?

laz*_*rus 11 timestamp

在阅读 Linux 时,我得到了以下信息:

touch 提供了几个选项,但这里有一个有趣的选项:

-t 选项允许您设置文件的日期和时间戳。要将时间戳设置为特定时间:

$ touch -t 03201600 myfile
Run Code Online (Sandbox Code Playgroud)

这会将文件 myfile 的时间戳设置为 3 月 20 日 (03 20 1600) 下午 4 点。

在这里,我没有理解 03201600 --> 3 月 20 日下午 4 点背后的逻辑。

Ala*_*Ali 23

欢迎来到 Linux!您可能touch从指南或书籍中阅读了您在问题中引用的文本。

在 Linux 中,几乎每个命令都有一个解释其选项的“手册”。您可以通过man <command>在 Linux 机器上执行来查看任何命令的手册页。

所以,从命令man touch

   -t STAMP
          use [[CC]YY]MMDDhhmm[.ss] instead of current time
Run Code Online (Sandbox Code Playgroud)

所以,你的例子:

-t 03201600

#分解:

-t 03 20 16 00
-t     MM      DD      hh      毫米
-t 月日时分

所以 3 月 20 日,下午 4 点(24 小时制)。

如果您无法访问 Linux 机器,您可以man从这里在线查看这些页面:http : //unixhelp.ed.ac.uk/CGI/man-cgi。该man命令的页面可以在touch这里找到:http : //unixhelp.ed.ac.uk/CGI/man-cgi?touch


Nat*_*gew 13

您发布的输出通过将数字分解为 (03 20 1600) 来解释格式:

03 - March
20 - 20th
1600 - 4:00 PM (24-hour clock, where 0000 is midnight)
Run Code Online (Sandbox Code Playgroud)


mur*_*uru 5

根据man touch

   -t STAMP
          use [[CC]YY]MMDDhhmm[.ss] instead of current time
Run Code Online (Sandbox Code Playgroud)

因此,您的时间戳可以转换为DD/MM hh:mm:20/03 16:00。