20

Is the hour component of NSDateComponent in a 12h or 24h format? I cannot find anything about this in the documentation...

Reinier Melian
  • 20,519
  • 3
  • 38
  • 55
Pétur Ingi Egilsson
  • 4,368
  • 5
  • 44
  • 72

1 Answers1

32

It's 24 hours, on the gregorian calendar.

Why? The documentation doesn't say it explicitly; however, it does state that the values are for whatever calendar is used. am/pm is just a different notation -- countries using am/pm still have 24 hours per day, they are just writing if differently.

Also, if you look at the available unit constants, you will notice there there is no "am/pm" constant. Again, that's because am/pm is a localized notation, not a property of the gregorian calendar.

EDIT: if you are asking this because you want to output a time in readable form, don't use NSDateComponents -- use NSDateFormatter.

Gabriel Jensen
  • 4,082
  • 1
  • 17
  • 14
Christian Stieber
  • 9,954
  • 24
  • 23