gpt4 book ai didi

linux - 为什么 `date -d @1270787111` 中需要前缀 @ ?

转载 作者:太空宇宙 更新时间:2023-11-04 09:45:06 25 4
gpt4 key购买 nike

我想将纪元时间转换为人类可读的格式。我在网上搜索,找到了一个

示例:date -d @1270787111

我重读了日期的手册。

-d, --date=STRING display time described by STRING, not 'now'

DATE STRING The --date=STRING is a mostly free...

我没有找到关于这种格式的任何信息。我错过了什么吗?

最佳答案

您所指的同一“DATE STRING”部分以以下句子结尾:

The date string format is more complex than is easily documented here but is fully described in the info documentation.

换句话说,您必须引用“信息”页面。您可以通过在终端中输入 info date 来完成此操作,或者在线查看这些文档。输入格式描述得很好here ,例如。

那么为什么date -d @1270787111 中需要前缀@?手册页示例中提到的带有 @ 的特定格式是 described in §28.8 :

28.8 Seconds since the Epoch

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.

关于linux - 为什么 `date -d @1270787111` 中需要前缀 @ ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16986293/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com