为什么要从1970年1月1日开始计算日期?

问题:为什么要从1970年1月1日开始计算日期?

使用date(1970年1月1日)作为时间操纵的默认标准有什么原因吗?我已经在Java和Python中看到了这个标准。我知道这两种语言。还有其他遵循相同标准的流行语言吗?

请描述。

Is there any reason behind using date(January 1st, 1970) as default standard for time manipulation? I have seen this standard in Java as well as in Python. These two languages I am aware of. Are there other popular languages which follows the same standard?

Please describe.


回答 0

这是Unix时间的标准

Unix时间(或POSIX时间)是一种用于描述时间点的系统,时间点定义为自1970年1月1日午夜多点协调世界时(UTC)起经过的秒数,不包括leap秒。

It is the standard of Unix time.

Unix time, or POSIX time, is a system for describing points in time, defined as the number of seconds elapsed since midnight proleptic Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds.


回答 1

使用日期(1970年1月1日)作为默认标准

该问题有两个错误的假设:

  • 自1970年以来,计算领域的所有时间跟踪工作都已开始。
  • 这种跟踪是标准的。

两个打时代

从1970年UTC开始并不总是跟踪计算时间。虽然那个时代参考很流行,但几十年来的各种计算环境至少使用了近二十个时代。有些来自其他世纪。范围从0年(零)到2001年。

这里有一些。

公元前1月1日,1月0日

公元1月1日,

1582年10月15日

1601年1月1日

1840年12月31日

1858年11月17日

1899年12月30日

1899年12月31日

1900年1月1日

1904年1月1日

1967年12月31日

1980年1月1日

1980年1月6日

2000年1月1日

2001年1月1日

Unix时代常见,但不占主导地位

1970年初开始流行,可能是因为它被Unix使用。但这绝不是主导。例如:

ISO 8601

假设count-since-epoch正在使用Unix纪元,将给漏洞带来很大的漏洞。对于人类来说,这样的计数是不可能立即解密的,因此在调试和记录日志时,不容易标记出错误或问题。另一个问题是下面解释的粒度不明确。

我强烈建议您将日期时间值序列化为明确的ISO 8601字符串以进行数据交换,而不是将整数count-since-epoch进行序列化:YYYY-MM-DDTHH:MM:SS.SSSZ例如2014-10-14T16:32:41.018Z

什么,自纪元

自计时以来时间跟踪的另一个问题是时间单位,通常至少使用四个级别的分辨率。

using date(January 1st, 1970) as default standard

The Question makes two false assumptions:

  • All time-tracking in computing is done as a count-since-1970.
  • Such tracking is standard.

Two Dozen Epochs

Time in computing is not always tracked from the beginning of 1970 UTC. While that epoch reference is popular, various computing environments over the decades have used at least nearly two dozen epochs. Some are from other centuries. They range from year 0 (zero) to 2001.

Here are a few.

January 0, 1 BC

January 1, AD 1

October 15, 1582

January 1, 1601

December 31, 1840

November 17, 1858

December 30, 1899

December 31, 1899

January 1, 1900

January 1, 1904

December 31, 1967

January 1, 1980

January 6, 1980

January 1, 2000

January 1, 2001

Unix Epoch Common, But Not Dominant

The beginning of 1970 is popular, probably because of its use by Unix. But by no means is that dominant. For example:

  • Countless millions (billions?) of Microsoft Excel & Lotus 1-2-3 documents use January 0, 1900 (December 31, 1899).
  • The world now has over a billion iOS/OS X devices using the Cocoa (NSDate) epoch of 1 January 2001, GMT.
  • The GPS satellite navigation system uses January 6, 1980 while the European alternative Galileo uses 22 August 1999.

ISO 8601

Assuming a count-since-epoch is using the Unix epoch is opening a big vulnerability for bugs. Such a count is impossible for a human to instantly decipher, so errors or issues won’t be easily flagged when debugging and logging. Another problem is the ambiguity of granularity explained below.

I strongly suggest instead serializing date-time values as unambiguous ISO 8601 strings for data interchange rather than an integer count-since-epoch: YYYY-MM-DDTHH:MM:SS.SSSZ such as 2014-10-14T16:32:41.018Z.

Count Of What Since Epoch

Another issue with count-since-epoch time tracking is the time unit, with at least four levels of resolution commonly used.


回答 2

为什么总是1970年1月1日,因为-1970年1月1日通常称为“时代日期”,是Unix计算机的开始时间,该时间戳记为“ 0”。自该日期以来的任何时间都是根据经过的秒数计算的。用简单的话来说…任何日期的时间戳都将是该日期与“ 1970年1月1日”之间的秒数差异。时间戳只是一个整数,它从“ 1970年1月1日午夜”的数字“ 0”开始并继续递增每隔一秒钟传递“ 1”,以将UNIX时间戳转换为可读日期PHP和其他开源语言提供了内置函数。

why its always 1st jan 1970 , Because – ‘1st January 1970’ usually called as “epoch date” is the date when the time started for Unix computers, and that timestamp is marked as ‘0’. Any time since that date is calculated based on the number of seconds elapsed. In simpler words… the timestamp of any date will be difference in seconds between that date and ‘1st January 1970’ The time stamp is just a integer which started from number ‘0’ on ‘Midnight 1st January 1970’ and goes on incrementing by ‘1’ as each second pass For conversion of UNIX timestamps to readable dates PHP and other open source languages provides built in functions.


回答 3

使用date(1970年1月1日)作为时间操纵的标准背后有什么原因吗?

没关系。

Python的time模块 C库。问肯·汤普森(Ken Thompson)为什么他选择那个日期作为一个时代的日期。也许是某人的生日。

Excel使用两个不同的时期。为什么不同版本的excel使用不同的日期?

除了真正的程序员之外,没有其他人会知道为什么做出这些决定。

和…

不要紧,为什么选择的日期。只是。

天文学家使用他们自己的时代日期:http : //en.wikipedia.org/wiki/Epoch_(天文学

为什么?必须选择一个日期来计算数学。任何随机的日期都可以。

过去的日期通常会避免使用负数。

一些更聪明的软件包使用了多功的公历1年。为什么是1年?
在诸如Calendrical Calculations之类的书中给出了一个原因:从数学上讲它稍微简单一些。

但是如果您考虑一下,1/1/1和1/1/1970之间的差异只是1969,这是一个微不足道的数学偏移量。

Is there any reason behind using date(January 1st, 1970) as standard for time manipulation?

No reason that matters.

Python’s time module is the C library. Ask Ken Thompson why he chose that date for an epochal date. Maybe it was someone’s birthday.

Excel uses two different epochs. Any reason why different version of excel use different dates?

Except for the actual programmer, no one else will ever know why those those kinds of decisions were made.

And…

It does not matter why the date was chosen. It just was.

Astronomers use their own epochal date: http://en.wikipedia.org/wiki/Epoch_(astronomy)

Why? A date has to be chosen to make the math work out. Any random date will work.

A date far in the past avoids negative numbers for the general case.

Some of the smarter packages use the proleptic Gregorian year 1. Any reason why year 1?
There’s a reason given in books like Calendrical Calculations: it’s mathematically slightly simpler.

But if you think about it, the difference between 1/1/1 and 1/1/1970 is just 1969, a trivial mathematical offset.


回答 4

1970年1月1日上午00:00:00是POSIX时间的零点。

January 1st, 1970 00:00:00 am is the zero-point of POSIX time.


回答 5

问: “为什么要从1970年1月1日开始计算日期?”

A)它必须尽可能新,但要包含一些过去。很多人也有同样的感觉,很可能没有其他明显的原因。

他们知道如果把它放到过去就太远了,就会构成问题;如果知道将来会带来负面的结果,他们就会知道。由于事件很可能会在未来发生,因此过去无需深入探讨。

注意: 另一方面,玛雅人需要将事件放到过去,因为他们了解很多过去,因此他们进行了长期压延。只是将所有常规现象放在压延机上。

时间戳并非日历,而是一个时代。而且我相信,玛雅人也使用相同的观点进行了长期压延。(这意味着他们非常了解自己与过去没有任何关系,只需要从更大的角度来看待过去)

Q) “Why are dates calculated from January 1st, 1970?”

A) It had to be as recent as possible, yet include some past. There was most likely no significant other reason as a lot of people feel that same way.

They knew it posed a problem if they placed it too far into the past and they knew it gave negative results if it was in the future. There was no need to go deeper in the past as events will most likely take place in the future.

Notes: The mayans, on the other hand, had the need to place events into the past, since the had the knowledge of a lot of past, for which they made a long-term calender. Just to place all the routine phenomena on the calender.

The timestamp was not meant as a calender, it’s an Epoch. And I believe the mayans made their long-term calender using that same perspective. (meaning they knew damn well they didn’t have any relations with the past, they just had the need to see it in a bigger scale)


回答 6

是的,C(及其家人)。这也是Java采取的方法。

Yes, C (and its family). This is where Java took it too.