9

I had an upvote on an old question of mine that happened to be early in the morning Stack Overflow time (UTC), and I noticed that there's no leading zero.

ISO 8601 specifies that all times shall have a leading zero (though durations may omit it).

So, as part of conforming to the ISO 8601 standard, Stack Overflow should show leading zeros for hours before 10 am.

e.g. Screenshot illustrating missing leading zeros for time of day

11
  • Odd that this has 09 upvotes. Oct 29 '11 at 0:33
  • SO time == UTC btw.
    – chown
    Oct 29 '11 at 1:13
  • 24
    Oh please no. I hate leading zeros when dates and times appear in normal text, and I live in a 24-hour country. And your "most 24-hour time systems" thing needs a citation.
    – balpha
    Oct 29 '11 at 5:17
  • 3
    I agree with balpha. Adding leading zeros is something for sorting or aligning, e.g in tabular data.
    – NGLN
    Oct 29 '11 at 12:19
  • 6
    The abscense of AM/PM suffix makes it clear it is in 24-hour format.
    – NGLN
    Oct 29 '11 at 12:21
  • 9
    @balpha, it's part of the ISO 8601 standard: en.wikipedia.org/wiki/24-hour_clock Oct 29 '11 at 14:39
  • 8
    I'm going to give you (valueless) bonus points for even attempting to pull the ISO 8601 card on a datetime that reads "Apr 29 at 0:57" while linking to a Wikipedia article about 24-hour time that says that the zero is optional for hours.
    – Tim Stone
    Oct 29 '11 at 19:03
  • 3
    @TimStone Huh, actually ISO-8601 requires padding zeroes. Oct 30 '11 at 15:26
  • @NullUserExceptionஇ_இ Yes, but that's largely unrelated to the "requirements" of 24-hour time itself (the bit about the leading zero being optional is in the 24-hour clock article).
    – Tim Stone
    Oct 30 '11 at 15:38
  • 2
    @TimStone I don't know where you are going with this. [hh] refers to a zero-padded hour between 00 and 24. I pulled the standard and it actually mandates leading zeroes (section 3.6) Oct 30 '11 at 15:53
  • 3
    @NullUserExceptionஇ_இ It mandates them for ISO 8601 datetimes, which "Apr 29 at 0:57" is not.
    – Tim Stone
    Oct 30 '11 at 16:11
11

If we want to go with the ISO 8601 standard, then do it fully, not only for the time portion. This would mean to write 2011-04-29 00:57 for your second example above.

If we leave the date as Apr 29 (or Apr 29 '11 for dates longer ago), then we don't have an ISO-formatted date anyways, so there is no point in the leading zero.

2
  • I'm assuming this answer is trying to point out that in this case, conforming to the standards might not be what we want to do?
    – John
    Oct 30 '11 at 2:18
  • 3
    I'm not really sure here. I would like the full ISO form of the date, but if we are going informal anyway ("Apr 29"), we can also stay without leading zeros. Oct 30 '11 at 2:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .