Difference between revisions of "Template:Format time"

From blackwiki
Jump to navigation Jump to search
test>Daviddwd
(Created page with '<includeonly><!--First, time: -->{{#if: {{{4| {{{hour| {{{hh|}}} }}} }}} |{{#if: {{{5| {{{minute| {{{mm|}}} }}} }}}| {{#if: {{{hour_format|}}}<!--if format provi...')
 
test>Daviddwd
Line 1: Line 1:
<includeonly><!--First, time: -->{{#if: {{{4| {{{hour| {{{hh|}}} }}} }}}
+
<includeonly><!--First, time: -->{{#if: {{{hour| {{{hh| {{{1|}}} }}} }}}
|{{#if: {{{5| {{{minute| {{{mm|}}} }}} }}}|
+
|{{#if: {{{minute| {{{mm|{{{2|}}} }}} }}}|
 
{{#if: {{{hour_format|}}}<!--if format provided, use it -->
 
{{#if: {{{hour_format|}}}<!--if format provided, use it -->
 
     |{{#time:
 
     |{{#time:
 
       {{#switch: {{{hour_format}}}
 
       {{#switch: {{{hour_format}}}
         | g = g:i{{#if: {{{6| {{{second| {{{ss| {{{sec| }}} }}} }}} }}}|&#58;s}} a
+
         | g = g:i{{#if: {{{second| {{{ss| {{{sec| {{{3| }}} }}} }}} }}}|&#58;s}} a
         | h = h:i{{#if: {{{6| {{{second| {{{ss| {{{sec| }}} }}} }}} }}}|&#58;s}} A
+
         | h = h:i{{#if: {{{second| {{{ss| {{{sec| {{{3| }}} }}} }}} }}}|&#58;s}} A
         | G = G:i{{#if: {{{6| {{{second| {{{ss| {{{sec| }}} }}} }}} }}}|&#58;s}}
+
         | G = G:i{{#if: {{{second| {{{ss| {{{sec| {{{3| }}} }}} }}} }}}|&#58;s}}
         | H = H:i{{#if: {{{6| {{{second| {{{ss| {{{sec| }}} }}} }}} }}}|&#58;s}}
+
         | H = H:i{{#if: {{{second| {{{ss| {{{sec| {{{3| }}} }}} }}} }}}|&#58;s}}
 
       }}
 
       }}
       |{{padleft: {{{4| {{{hour| {{{hh|}}} }}} }}}|2|0
+
       |{{padleft: {{{hour| {{{hh| {{{1|}}} }}} }}}|2|0
         }}:{{padleft:{{{5| {{{minute| {{{mm|}}} }}} }}}|2|0
+
         }}:{{padleft:{{{minute| {{{mm|{{{2| }}} }}} }}}|2|0
         }}:{{padleft:{{{6| {{{second| {{{ss| {{{sec|0}}} }}} }}} }}}|2|0
+
         }}:{{padleft:{{{second| {{{ss| {{{sec| {{{3| }}} }}} }}} }}}|2|0
 
       }}
 
       }}
 
     }}
 
     }}
 
     <!--if no format provided, default to pad left -->
 
     <!--if no format provided, default to pad left -->
     |{{#if: {{{5| {{{minute| {{{mm|}}} }}} }}}
+
     |{{#if: {{{minute| {{{mm|{{{2|}}} }}} }}}
       |{{padleft:{{{4| {{{hour| {{{hh|}}} }}} }}}|2|0}}:{{padleft:
+
       |{{padleft:{{{hour| {{{hh| {{{1|}}} }}} }}}|2|0}}:{{padleft:
         {{{5| {{{minute| {{{mm|}}} }}} }}}|2|0
+
         {{{minute| {{{mm|{{{2|}}} }}} }}}|2|0
       }}{{#if: {{{6| {{{second| {{{ss| {{{sec| }}} }}} }}} }}}
+
       }}{{#if: {{{second| {{{ss| {{{sec| {{{3| }}} }}} }}} }}}
           |&#58;{{padleft:{{{6| {{{second| {{{ss| {{{sec| }}} }}} }}} }}}|2|0}}
+
           |&#58;{{padleft:{{{second| {{{ss| {{{sec| {{{3| }}} }}} }}} }}}|2|0}}
 
       }}
 
       }}
 
     }}
 
     }}
   }}{{#if:{{{time_joiner|}}}|&#32;{{{time_joiner}}}|{{#if: {{{1| {{{year|}}} }}}|,}} }}&#32;
+
   }}
 
}}<!--minute-->}}</includeonly><noinclude>
 
}}<!--minute-->}}</includeonly><noinclude>
 
{{Documentation}}
 
{{Documentation}}
 
</noinclude>
 
</noinclude>

Revision as of 19:19, 12 December 2018

Template documentation[view] [edit] [history] [purge]

Syntax

Parameters

  • {{{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 Script error: No such module "Section link"..

Examples:


Hour format

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/G) or 24 hour time (h/H), and whether to truncate (g/h) numbers under 10 or not (G/H).

Examples:


See also

[edit] all subsections that follow:

Multiple units of time

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)
{{DATE}} (prefixed by date=)
{{TODAY}} (DMY)
{{Yesterday}}
{{Day-1}}
{{Tomorrow}}
{{Day+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

Unit of time Adjustable Current Last Next
SECOND {{CURRENTSECOND}}
MINUTE {{CURRENTMINUTE}}
HOUR {{CURRENTHOUR}} {{Hour-1}} {{Hour+1}}
WEEK {{CURRENTWEEK}}
{{CURRENTWEEKOFMONTH}}
Day of Week {{Dow}} {{CURRENTDAYNAME}}
{{CURRENTWEEKDAYABBREV}}
{{CURRENTWEEKDAY}}
{{LASTWEEKDAYNAME}}
{{LASTWEEKDAYABBREV}}
{{NEXTWEEKDAYNAME}}
{{NEXTWEEKDAYABBREV}}
MONTH {{MONTHNAME}}
{{MONTHABBREV}}
{{MONTHNUMBER}}
{{MONTH}} (zero padded)
{{CURRENTMONTHNAME}}
{{CURRENTMONTHABBREV}}
{{CURRENTMONTH1}}
{{CURRENTMONTHDAYS}}
{{LASTMONTH}}
(Can make not zero-padded)
{{LASTMONTHNAME}}
{{LASTMONTHABBR}}
{{NEXTMONTH}}
(Can make not zero-padded)
{{NEXTMONTHNAME}}
{{NEXTMONTHABBR}}
Day of Month {{CURRENTDAY}}
{{CURRENTDAY2}} (zero padded)
YEAR {{CURRENTYEARCC}}
{{CURRENTYEARYY}}
{{CURRENTISOYEAR}}
{{CURRENTYEAR}}
{{LASTYEAR}} {{NEXTYEAR}}
Day of Year {{CURRENTDAYOFYEAR}}
DECADE {{DECADE}} {{CURRENTDECADE}} {{LASTDECADE}} {{NEXTDECADE}}
CENTURY {{CENTURY}} {{CURRENTCENTURY}} {{LASTCENTURY}} {{NEXTCENTURY}}
MILLENNIUM {{MILLENNIUM}} {{Currentmillennium}}

Date and time templates made for substitution:

Month:
{{Lmonth}} produces Oct
{{Nmonth}} produces Dec
{{LastMonth}} produces October 2025
{{NextMonth}} produces December 2025


Individual templates

Categories of templates

Template Data

This is the TemplateData documentation for this template used by VisualEditor and other tools; see the monthly parameter usage report for this template.

TemplateData for Format time


Formats a time of day

Template parameters

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