4

如何表示一天的开始和结束时间?

以 2008 年 10 月 23 日为例,它是从 2008-10-23 12:00:00 AM 开始到 2008-10-23 11:59:59 PM 结束吗?

4

7 回答 7

15

我想引用一个网站,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:

  • It is longer than the normal 24h notation.
  • It takes somewhat more time for humans to compare two times in 12h notation.
  • It is not clear, how 00:00, 12:00 and 24:00 are represented. Even encyclopedias and style manuals contain contradicting descriptions and a common quick fix seems to be to avoid “12:00 a.m./p.m.” altogether and write “noon”, “midnight”, or “12:01 a.m./p.m.” instead, although the word “midnight” still does not distinguish between 00:00 and 24:00 (midnight at the start or end of a given day).
  • It makes people often believe that the next day starts at the overflow from “12:59 a.m.” to “1:00 a.m.”, which is a common problem not only when people try to program the timer of VCRs shortly after midnight.
  • It is not easily comparable with a string compare operation.
  • It is not immediately clear for the unaware, whether the time between “12:00 a.m./p.m.” and “1:00 a.m./p.m.” starts at 00:00 or at 12:00, i.e. the English 12h notation is more difficult to understand.

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.

于 2008-10-20T09:24:01.053 回答
4

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?

于 2008-10-20T09:47:53.457 回答
2

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.

于 2008-10-20T09:40:02.193 回答
1

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

于 2008-10-20T09:26:03.017 回答
1

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 .

于 2008-10-20T09:27:49.097 回答
1

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.

于 2008-10-20T10:20:57.010 回答
1

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.

于 2008-10-20T10:41:18.747 回答