php 24:00 和 00:00 之间的区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13060467/
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
Difference between 24:00 and 00:00?
提问by Gigamegs
What is the difference between 24:00 clock and 00:00 clock. IMO 24:00 clock is the day before and 00:00 clock is the beginning of the new day. But I'm not really convinced and I'm new to date programming
24:00 时钟和 00:00 时钟有什么区别。IMO 24:00 时钟是前一天,00:00 时钟是新一天的开始。但我并不真的相信而且我是新来的编程
Update: Here is what wikipedia article say about military time and style guide about how to deal with 24:00 and 00:00 confusion: http://en.m.wikipedia.org/wiki/24-hour_clock#section_1.
更新:以下是维基百科文章关于如何处理 24:00 和 00:00 混淆的军事时间和风格指南:http: //en.m.wikipedia.org/wiki/24-hour_clock#section_1。
回答by bfavaretto
There is no 24:00. It's just that PHP understandswhen you input 24:00, instead of throwing an error, or returning false(like before 5.3). If you tell PHP 24:00 today, it will understand 00:00 tomorrow. And they're both the same moment in PHP's time representation.
没有24:00。只是 PHP理解您何时输入24:00,而不是抛出错误或返回false(如 5.3 之前)。如果你告诉 PHP 24:00 today,它就会明白00:00 tomorrow。它们在 PHP 的时间表示中都是同一时刻。
You can tellPHP it's 24:00, but when you askPHP, it will always say 00:00. 24:00is just another way of saying 00:00the following day. There is no zero-length extra second (or something) between 23:59and 00:00.
您可以告诉PHP 它是24:00,但是当您询问PHP 时,它总是会说00:00. 24:00只是00:00第二天的另一种说法。23:59和之间没有零长度的额外秒(或其他东西)00:00。
So, I don't understand when you say you can't schedule something for every Saturday at midnight, while you actually have two ways to schedule that: Fri 24:00or Sat 00:00. No reason for using Sat 00:01.
所以,我不明白你什么时候说你不能在每个星期六的午夜安排一些事情,而你实际上有两种安排方式:Fri 24:00或Sat 00:00。没有理由使用Sat 00:01.
回答by Grzegorz
After 23:59 comes 0:00, not 24:00 Please see the code below, in php, as you put the 'php' tag:
23:59 之后是 0:00,而不是 24:00 请参见下面的代码,在 php 中,当您放置“php”标签时:
echo date('G:i:s', mktime(0,0,0)) . "\n" ;
echo date('G:i:s', mktime(0,0,0)-1) . "\n" ;
It will display:
它将显示:
0:00:00
23:59:59
回答by Baba
The notation 24:00 mainly serves to refer to the exact end of a day in a time interval. The last minute of the day begins at 23:59 in the 24 hour time
符号 24:00 主要用于表示时间间隔中一天的确切结束时间。一天的最后一分钟从 24 小时制的 23:59 开始
24:00 = midnight (end of day) shown as start of next day
00:00 = midnight (start of day)
24:00 = 午夜(一天结束)显示为第二天的开始
00:00 = 午夜(一天开始)
But really 24:00 = 00:00... no difference but due to compatibility issue i would recommend you use 00:00
但真的24:00 = 00:00......没有区别,但由于兼容性问题,我建议您使用00:00
回答by hakre
Just try it yourself (which you should have done with your question so the relation to PHP becomes more clear):
自己尝试一下(您应该已经完成了您的问题,以便与 PHP 的关系变得更加清晰):
echo '00:00 - ', date('r', strtotime('00:00')),
"\n24:00 - ", date('r', strtotime('24:00'));
Gives the following output (Demo):
给出以下输出(演示):
00:00 - Thu, 25 Oct 2012 00:00:00 +0000
24:00 - Fri, 26 Oct 2012 00:00:00 +0000
Next thing you could have done (and @Baba pointed to it already) is to just check some resources first like (as a very first step) Wikipedia.
你可以做的下一件事(@Baba 已经指出了它)是首先检查一些资源,比如(作为第一步)维基百科。
回答by Gavin
The concept of 00:00 / 24:00 is a familiar one to me working in China - in my situation I have dealt with it in terms the coverage period of insurance policies:
00:00 / 24:00 的概念对于在china工作的我来说是一个熟悉的概念——在我的情况下,我是从保单的保障期来处理它的:
An annual policy with an effective date of 01/OCT/2013 24:00 would give coverage from 1st October 2013 to 30th September 2014.
生效日期为 01/OCT/2013 24:00 的年度保单将涵盖 2013 年 10 月 1 日至 2014 年 9 月 30 日。
An annual policy with an effective date of 01/OCT/2013 00:00 would give coverage from 2nd October 2013 to 1st October 2014.
生效日期为 01/OCT/2013 00:00 的年度保单将涵盖 2013 年 10 月 2 日至 2014 年 10 月 1 日。
回答by Nicholas
Let's convert 24 hour time to 12 hour time. If it's 11:59 PM, in 1 minute it would be 12:00 AM. AM refers to the beginning of the day, and PM refers to the end of the day. If you use 24:00, you would be referring to the end of the day (PM), and 12:00 PM is not at night. So use 00:00.
让我们将 24 小时制转换为 12 小时制。如果现在是晚上 11:59,则 1 分钟后就是上午 12:00。AM 表示一天的开始,PM 表示一天的结束。如果使用 24:00,则指的是一天结束 (PM),而 12:00 PM 不是晚上。所以使用 00:00。
回答by Jem Marsh
24:00 is a valid time and it is not quitethe same as 00:00 - its a full 24 hours ahead of 00:00
24:00 是一个有效时间,它与 00:00不太一样——它比 00:00 提前了整整 24 小时
00:00 on the 25th December is the start of Christmas Day.
12 月 25 日的 00:00 是圣诞节的开始。
24:00 on the 25th December is the END of Christmas Day. You could say that it is 00:00 on Boxing Day.
12 月 25 日 24:00 是圣诞节的结束。你可以说这是节礼日的 00:00。
A Boxing Day Sale might start at 00:00 on Boxing Day - and it might end at 24:00 on Boxing Day. Far more convenient than saying 23:59:59.
节礼日促销可能在节礼日 00:00 开始 - 可能在节礼日 24:00 结束。远比说 23:59:59 方便得多。
回答by favoretti
24:00has no difference as to 00:00. The only difference in PHP versions is that prior to 5.3.0 strtotime("24:00")would give you FALSEback, when 5.3.0+ will accept it as a valid equivalent of a 00:00
24:00没有区别00:00。PHP 版本的唯一区别是 5.3.0 之前的版本strtotime("24:00")会给你FALSE回馈,当 5.3.0+ 将接受它作为一个有效的等价物时00:00

