如何表示一天的开始和结束时间?
以 2008 年 10 月 23 日为例,它是从 2008-10-23 12:00:00 AM 开始到 2008-10-23 11:59:59 PM 结束吗?
如何表示一天的开始和结束时间?
以 2008 年 10 月 23 日为例,它是从 2008-10-23 12:00:00 AM 开始到 2008-10-23 11:59:59 PM 结束吗?
我想引用一个网站,http://www.cl.cam.ac.uk/~mgk25/iso-time.html
一天中时间的国际标准符号是
hh:mm:ss
其中 hh 是自午夜 (00-24) 以来经过的完整小时数,mm 是自一小时开始 (00-59) 以来经过的完整分钟数,ss 是自午夜 (00-59) 以来经过的完整秒数分钟的开始 (00-60)。如果小时值为 24,则分钟和秒值必须为零。
注意: ss 的值 60 有时可能需要在原子时间尺度(如协调世界时 (UTC))中插入闰秒。正如巴黎国际地球自转服务所宣布的那样,每隔几年将一个闰秒 23:59:60 插入 UTC 时间尺度,以防止 UTC 偏离不太恒定的天文时间尺度 UT1 超过 0.9 秒,这由地球的实际自转定义。实际上,您不太可能看到时钟显示 23:59:60。大多数同步时钟在闰秒发生后的某个时间再次与 UTC 重新同步,或者它们在闰秒时间附近暂时放慢速度,以避免超出范围的时间戳可能导致的任何中断。
一个示例时间是
23:59:59
表示午夜前一秒的时间。
与日期符号一样,分隔冒号也可以省略,如
235959
并且可以通过省略秒或秒和分钟来降低精度,如
23:59, 2359, or 23
也可以在小数点或逗号后添加秒的小数部分,例如午夜前 5.8 毫秒的时间可以写为
23:59:59.9942 or 235959.9942
由于每一天都以午夜开始和结束,因此可以使用两种符号 00:00 和 24:00 来区分可以与一个日期相关联的两个午夜。这意味着以下两个符号指的是完全相同的时间点:
1995-02-04 24:00 = 1995-02-05 00:00
如果需要明确表示时间,00:00 通常是午夜而不是 24:00 的首选表示法。数字时钟显示 00:00 而不是 24:00。
ISO 8601 does not specify, whether its notations specify a point in time or a time period. This means for example that ISO 8601 does not define whether 09:00 refers to the exact end of the ninth hour of the day or the period from 09:00 to 09:01 or anything else. The users of the standard must somehow agree on the exact interpretation of the time notation if this should be of any concern.
If a date and a time are displayed on the same line, then always write the date in front of the time. If a date and a time value are stored together in a single data field, then ISO 8601 suggests that they should be separated by a latin capital letter T, as in 19951231T235959.
A remark for readers from the U.S.:
The 24h time notation specified here has already been the de-facto standard all over the world in written language for decades. The only exception are a few English speaking countries, where still notations with hours between 1 and 12 and additions like “a.m.” and “p.m.” are in wide use. The common 24h international standard notation is widely used now even in England (e.g. at airports, cinemas, bus/train timetables, etc.). Most other languages do not even have abbreviations like “a.m.” and “p.m.” and the 12h notation is certainly hardly ever used on Continental Europe to write or display a time. Even in the U.S., the military and computer programmers have been using the 24h notation for a long time.
The old English 12h notation has many disadvantages like:
Please consider the 12h time to be a relic from the dark ages when Roman numerals were used, the number zero had not yet been invented and analog clocks were the only known form of displaying a time. Please avoid using it today, especially in technical applications! Even in the U.S., the widely respected Chicago Manual of Style now recommends using the international standard time notation in publications.
Surely, if you just want to represent 1 day, you don't need to include the time at all - especially as this raises such a level of discussion about when a day starts or ends. In my experience, date handling is usually complicated enough, without introducing any extra complexity.
Today is Oct 20th 2008 - no more information is necessary.
Or am I missing something?
Oct. 23 starts at 2008-10-23 12AM and finishes at 2008-10-24 12AM—a day ends at the exact same point the next one begins. The very last second begins at 11:59:59 PM but you still have a whole second before the day is over.
Your notation is strange. I'd suggest the standard way of specifying a full day range is:
2008-10-23 00:00:00 and finish 2008-10-23 23:59:59
The definition of the day you mention in the question is any time that is >= 2008-10-23 00:00:00 and < 2008-10-24 00:00:00 .
If you were to use mathematical interval notation, you would write it as
[2008-10-23 00:00:00 , 2008-10-24 00:00:00)
The [ means inclusion, and ) means up to but not including.
In this way you make it easier for users and for yourself.
It depends what you mean by a day. Date handling is, sadly, always more complex than it looks.
To convert your example into 24h ISO date format, you'd say:
2008-10-23 00:00:00 - 2008-10-23 23:59:59
However depending on whether you interpret a range as inclusive or exclusive that could omit the last second of the day*. Programmers normally prefer to keep the upper bound exclusive, so you'd go for:
2008-10-23 00:00:00 - 2008-10-24 00:00:00
Or, as a slightly nicer way of stating the same, if supported (or for human readability):
2008-10-23 00:00:00 - 2008-10-23 24:00:00
*: actually possibly more than one. If the span represents a day in the UTC timezone (or another timezone aligned to it, which is quite likely), there can occasionally be an extra 'leap second' at the end of the day, 23:59:60, in a pointless attempt to keep UTC in line with sidereal time. The next leap second is planned for the end of this year. However, many systems ignore leap seconds because they're silly and annoying.
If you want to represent a 'calendar day' independently of timezones your best bet is the Julian day number. Today is 2454760.