• Home
  • Random
  • Nearby
  • Log in
  • Settings
Donate Now If Wikipedia is useful to you, please give today.
  • About Wikipedia
  • Disclaimers
Wikipedia

Template:Format time/sandbox

  • Template
  • Talk
  • Language
  • Watch
  • Edit
< Template:Format time
This is the template sandbox page for Template:Format time (diff).
See also the companion subpage for test cases.
Template documentation[view] [edit] [history] [purge]

Contents

  • 1 Syntax
  • 2 Parameters
    • 2.1 Hour format
  • 3 See also
    • 3.1 Multiple units of time
    • 3.2 Single units of time
    • 3.3 Date and time templates made for substitution:
      • 3.3.1 Parser functions
      • 3.3.2 Individual templates
      • 3.3.3 Categories of templates
  • 4 Template Data

Syntax

edit
  • {{Format time|hour|minute|second}}
  • {{Format time|hour|minute|second|TimeZone|hour_format=(format)}}

Parameters

edit
  • {{{hour}}} is required, and is the hour in 24 hour format.
    • aliases: {{{hh}}} and {{{1}}} (the first positional parameter)
  • {{{minute}}} is recommended; it is the minute after the hour (default 0).
    • aliases: {{{mm}}} and {{{2}}} (the second positional parameter)
  • {{{second}}} is optional; seconds will only be rendered if this is not blank.
    • aliases: {{{ss}}}, {{{sec}}} and {{{3}}} (the third positional parameter)
  • {{{TimeZone}}} may be a numerical value, or "Z" for UTC; see examples.
    • aliases: {{{timezone}}}, {{{tz}}} and {{{4}}} (the fourth positional parameter)
  • {{{hour_format}}} can be blank, 'h', 'H', 'g' or 'G'; see §§ Hour format​ and below.

Examples:

  • {{Format time|08|30}} returns "08:30"
  • {{Format time|08|30|23}} returns "08:30:23"
  • {{Format time|08|30|tz=Z}} returns "08:30 (UTC)"
  • {{Format time|08|30|23|timezone=+01:00}} returns "08:30:23 (+01:00)"
  • {{Format time|08|30|23|TimeZone=-07:00}} returns "08:30:23 (-07:00)"


Hour format

edit

The hour format parameter {{{hour_format}}} can be variously 'g', 'G', 'h', or 'H', specifying whether to use 12 hour time with AM/PM (g/h) or 24 hour time (G/H), and whether to truncate (g/G) numbers under 10 or not (h/H).

Examples:

  • {{Format time|08|30|hour_format=g}} returns "8:30 am"
  • {{Format time|17|15|hour_format=g}} returns "5:15 pm"


  • {{Format time|08|30|hour_format=h}} returns "08:30 AM"
  • {{Format time|17|15|hour_format=h}} returns "05:15 PM"


  • {{Format time|08|30|hour_format=G}} returns "8:30"
  • {{Format time|17|15|hour_format=G}} returns "17:15"


  • {{Format time|08|30|hour_format=H}} returns "08:30"
  • {{Format time|17|15|hour_format=H}} returns "17:15"

See also

edit
  • {{Format date}} for dates, with times optional
For the magic words with the same or similar names, see MediaWikiWiki:Help:Magic words § Date and time.
  • v
  • t
  • e

Multiple units of time

edit
Type Adjustable Current Last Next
Date and time {{time}} {{Currentdate}} (MDY)
{{Plain now}} (DMY)
{{Now}} (DMY in a complete sentence)
{{Simple now}}
Date only {{Dateonly}}
{{Datedow}}
(Has the day of the week)
{{Date}} (Chose format)
{{TODAY}} (DMY)
{{Yesterday}}
{{Day-1}}
{{Tomorrow}}
{{Day+1}}
Month and year only {{Monthyear}}

{{DATE}} (prefixed by date=)

{{Monthyear-1}} {{Monthyear+1}}
Time only {{Timeonly}} {{CURRENTTIME}} (12 h format)
{{CURRENTTIME24}} (24 h format)
Banners {{Right now}}
(Blue with time and number of Wikipedia articles)
Timestamp {{Timestamp}}
(Format YYYYMMDDhhmmss)

Single units of time

edit
Unit of time Adjustable Current Last Next
Second {{CURRENTSECOND}}
Minute {{CURRENTMINUTE}}
Hour {{CURRENTHOUR}}
Week {{CURRENTWEEK}}
{{CURRENTWEEKOFMONTH}}
Day of Week {{DAYOFWEEK}} {{CURRENTDAYNAME}}
{{CURRENTWEEKDAYABBREV}}
{{CURRENTWEEKDAY}}
Month {{MONTHNAME}}
{{MONTHABBREV}}
{{MONTHNUMBER}}
{{MONTH}} (zero padded)
{{CURRENTMONTHNAME}}
{{CURRENTMONTHABBREV}}
{{CURRENTMONTH1}}
{{CURRENTMONTHDAYS}}
{{LASTMONTHNAME}} {{NEXTMONTHNAME}}
Day of Month {{CURRENTDAY}}
{{CURRENTDAY2}} (zero padded)
Year {{CURRENTYEARCC}}
{{CURRENTYEARYY}}
{{CURRENTISOYEAR}}
{{CURRENTYEAR}}
{{LASTYEAR}} {{NEXTYEAR}}
Day of Year {{CURRENTDAYOFYEAR}}
Decade {{DECADE}} {{CURRENTDECADE}}
Century {{Century}} {{CURRENTCENTURY}}
MILLENNIUM {{MILLENNIUM}}

Date and time templates made for substitution:

edit

Month:
{{Lmonth}} produces Jul
{{Nmonth}} produces Sep
{{Last month}} produces July 2025
{{Next month}} produces September 2025


Parser functions

edit
  • mw:Special:MyLanguage/time permits a custom time specifier string, similar to the C date and time functions

Individual templates

edit
  • {{Calendar}}
  • {{Calendar clock with Wikipedia stats}}
  • {{Clock}}
  • {{Digital clock}}
  • {{Digital clock and date}}
  • {{Infobox calendar date today}}
  • {{Raph Williams65/digiclock}}

Categories of templates

edit
  • Category:Time, date and calendar templates
  • Category:Date-computing templates
  • Category:Date-computing templates based on current time
  • Category:ISO date templates
  • Category:Calendar templates

Template Data

edit
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Format time in articles based on its TemplateData.

TemplateData for Format time


Formats a time of day

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
Hourhour hh 1

Hour of the day, in 24 hour format

Example
13
Auto value
Numberrequired
Minuteminute mm 2

minutes after the hour

Example
3
Auto value
0
Numbersuggested
Secondsecond ss sec 3

Seconds after the minute

Numberoptional
Hour formathour_format

Formats hours and whether to render AM/PM or a.m./p.m.

Example
g (7:00 p.m.), G (07:00 PM), h (19:00), or H (19:00)
Stringsuggested
timezonetimezone tz TimeZone 4

A numerical offset from UTC, or 'Z'. If non-empty, shows time zone

Example
Z
Stringoptional
The above documentation is transcluded from Template:Format time/doc. (edit | history)
Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.
Add categories to the /doc subpage. Subpages of this template.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Template:Format_time/sandbox&oldid=873371115"
Last edited on 12 December 2018, at 19:45

Languages

      This page is not available in other languages.

      Wikipedia
      • Wikimedia Foundation
      • Powered by MediaWiki
      • This page was last edited on 12 December 2018, at 19:45 (UTC).
      • Content is available under CC BY-SA 4.0 unless otherwise noted.
      • Privacy policy
      • About Wikipedia
      • Disclaimers
      • Contact Wikipedia
      • Code of Conduct
      • Developers
      • Statistics
      • Cookie statement
      • Terms of Use
      • Desktop