Jump to content

Template:HOUR12/doc

From Wikipedia, the free encyclopedia

Returns the hour in 12-hours format for the hour in 24-hour format (between 0 and 24) in parameter:

  • 00 (midnight at start of day) is normally 12 AM for the whole morning hour between 00:00 and 00:59.
  • 01..11 (end of night and morning) is unambiguously 01..11 AM.
  • 12 (noon) is normally 12 PM for the whole afternoon hour between 12:00 and 12:59.
  • 13..23 (afternoon and start of night) is unambiguously 01..11 PM.
  • 24 (midnight at end of day) is normally 12 AM (but the date must be adjusted when using the 12-hour format).
Syntax:
{{HOUR12|hour24}}
Synonym:
{{hour12|hour24}}
Examples for AM hours:
  • "{{HOUR12|24}}" returns "12"
  • "{{HOUR12|0}}" returns "12"
  • "{{HOUR12|00}}" returns "12"
  • "{{HOUR12|1}}" returns "01"
  • "{{HOUR12|01}}" returns "01"
  • "{{HOUR12|2}}" returns "02"
  • "{{HOUR12|02}}" returns "02"
  • "{{HOUR12|9}}" returns "09"
  • "{{HOUR12|09}}" returns "09"
  • "{{HOUR12|10}}" returns "10"
  • "{{HOUR12|11}}" returns "11"
Examples for PM hours:
  • "{{HOUR12|12}}" returns "12"
  • "{{HOUR12|13}}" returns "01"
  • "{{HOUR12|14}}" returns "02"
  • "{{HOUR12|15}}" returns "03"
  • "{{HOUR12|21}}" returns "09"
  • "{{HOUR12|22}}" returns "10"
  • "{{HOUR12|23}}" returns "11"
Removing the padding:
  • "{{#expr:{{HOUR12|09}}}}" returns "9"
See also: