php 1969 年 12 月 31 日晚上 7:00 发生了什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2390463/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What happened on Dec 31 1969 at 7:00 PM
提问by David
Every time in PHP when I make a variable such as this one:
每次在 PHP 中,当我创建一个这样的变量时:
$date = strtotime($row['date']);
$date = date("M d Y \a\t g:i A", $date); // Mmm dd YYYY at h:mm PM/AM
and somehow row['date']happens to be 0, the date Dec 31 1969 at 7:00 PMis displayed on the screen? Google does not tell me much, I was wondering if this date had any significances.
不知何故row['date']恰好是0,日期Dec 31 1969 at 7:00 PM显示在屏幕上?谷歌没有告诉我太多,我想知道这个日期是否有任何意义。
回答by echo
The Unix epoch is the time 00:00:00 UTC on 1 January 1970. This is the reference point for all time stamps. When you use PHP's date/time functions, you're always working with the number of seconds since the epoch. Time 0 is the epoch, and you (or your web server) must be on the east coast of the US, which is 5 hours behind UTC time.
Unix 纪元是 1970 年 1 月 1 日 UTC 时间 00:00:00。这是所有时间戳的参考点。当您使用 PHP 的日期/时间函数时,您总是使用自纪元以来的秒数。时间 0 是纪元,您(或您的 Web 服务器)必须位于美国东海岸,比 UTC 时间晚 5 小时。
回答by T Nguyen
I find it funny that not a single response here attempted to answer your actual question, which was (if I can paraphrase) "What is the significance of the actual date of Unix epoch time"?
我觉得有趣的是,这里没有一个回复试图回答您的实际问题,即(如果我可以解释)“Unix 纪元时间的实际日期的意义是什么”?
I'm not an expert on the subject but basically, as I understand it, the concept of epoch time was invented in 1971. The programmers chose the arbitrary date of January 1, 1971 GMT to be epoch time. This was partly due to the fact that older computers couldn't handle large numbers so the date had to be in the recent past. Afterwards, epoch time was adjusted to be Jan 1, 1970 so as to be a nice, round number.
我不是这方面的专家,但基本上,据我所知,纪元时间的概念是在 1971 年发明的。程序员选择了格林威治标准时间 1971 年 1 月 1 日的任意日期作为纪元时间。部分原因是旧计算机无法处理大量数据,因此日期必须是最近的过去。之后,纪元时间被调整为 1970 年 1 月 1 日,以便成为一个很好的整数。
So basically, nothing "happened" on that date. It was an arbitrary date chosen based on the original time of the work being done.
所以基本上,在那一天没有“发生”任何事情。这是根据完成工作的原始时间选择的任意日期。
回答by Amber
Unix timestampsare measured in "time since the Unix Epoch", which is Midnight GMT at the end of Dec. 31 1969 (a.k.a. 00:00 GMT Jan 1 1970). Since you appear to be on Eastern Standard Time, which is GMT-5, you get 7pm Dec. 31st 1969 for a unix timestamp value of 0.
Unix 时间戳以“自Unix 纪元以来的时间”来衡量,即 1969 年 12 月 31 日结束的午夜格林威治标准时间(又名格林威治标准时间 1970 年 1 月 1 日 00:00)。由于您似乎在东部标准时间,即 GMT-5,您将得到 1969 年 12 月 31 日晚上 7 点,Unix 时间戳值为 0。
回答by Michael Borgwardt
Let me guess: you live on the east coast of the USA?
让我猜猜:你住在美国东海岸吗?
PHP, like many other systems uses the Unix epochto measure time, i.e. a value of 0 represents January 1, 1970, midnight UTC - which is the same as Dec 31 1969 at 7:00 PM Eastern Standard Time.
PHP 与许多其他系统一样使用Unix 纪元来测量时间,即 0 值表示 1970 年 1 月 1 日,UTC 午夜 - 与 1969 年 12 月 31 日晚上 7:00 东部标准时间相同。
回答by Austin Fitzpatrick
One format in which date objects are stored is the time in seconds that have elapsed from an arbitrary start time. Asking for a formatted version of "0" is like asking for that arbitrary start time. I don't remember why that date was chosen, but I'm sure Wikipedia does. See the article on Unix time below.
存储日期对象的一种格式是从任意开始时间经过的时间(以秒为单位)。要求格式化版本的“0”就像要求任意的开始时间。我不记得为什么选择那个日期,但我确定维基百科知道。请参阅下面有关 Unix 时间的文章。

