Template:Digital clock

From Vixrapedia
Jump to navigation Jump to search
LED digit 0.pngLED digit 6.pngLED colon.pngLED digit 1.pngLED digit 8.png
Template documentation[view] [edit] [history] [purge]

This clock uses one of the most complicated structures to produce an digital clock that displays time in the offset you set!

Usage[edit]

  1. To use this template, place the following on the page - {{Digital clock}}
  2. This template should never be substituted.
  3. This template should be purged to reflect current time.
  4. If your area follows DST, you will have yo change the time manually.

Parameters[edit]

All parameters given below are optional and not necessarily be used.

{{Digital clock
|format = 12 or 24 (default: 24)
|offset = number of hours + or - UTC (default: 0)
|size = width of each digit in pixels (default: 70)
|color = any color name or HTML color code (default: red)
}}

Offset[edit]

The clock has a parameter that allows you to give an offset from UTC time. The offset can be fractional to adjust the time by any number of hours and minutes. Therefore this code - {{Digital clock|offset = +5.5}} will produce this clock:

LED digit 1.pngLED digit 1.pngLED colon.pngLED digit 4.pngLED digit 8.png

Format (12 or 24 hours)[edit]

You can set the format parameter to 12 or 24 to get a 12 or 24 hour time format! 12 hour clocks get an additional segment space for displaying am/pm. Therefore {{Digital clock|format = 12}} will produce:
 LED digit 6.pngLED colon.pngLED digit 1.pngLED digit 8.pngLED am.png

Size[edit]

You can set nearly all sizes for the clock to display. It defaults to 70x112px. To set a size of 20 pixels you will have to type {{Digital clock|size = 20px}} and it will display something like this:
LED digit 0.pngLED digit 6.pngLED colon.pngLED digit 1.pngLED digit 8.png

Color[edit]

You can set all types of colors for the clock to display. It defaults to red. You can use a HTML color code or directly write the color name. To display a clock with cyan color you will have to type {{Digital clock|color = cyan}} and it will display something like this:
LED digit 0.pngLED digit 6.pngLED colon.pngLED digit 1.pngLED digit 8.png

Borders[edit]

This is actually not a parameter but a way to design different types of borders for the clock. Normal HTML can be used to add borders and padding space. One tricky bit is that <div> elements expand to the full width of their container, which will make the box too wide. So we must specify an exact width for it, by multiplying the segment size by 5 (for 24-hour clocks) or 6 (for 12-hour clocks): A complete list of borders is available at the User Page Design Center

<div style="background:black; padding:5px 15px; border:3px inset cyan; width:300px;"> {{Digital clock}} </div>

 LED digit 6.pngLED colon.pngLED digit 1.pngLED digit 8.pngLED am.png

<div style="background:black; padding:5px 15px; border:3px inset cyan; -moz-border-radius:15px; -webkit-border-radius:15px; width:300px;"> {{Digital clock}} </div>

 LED digit 6.pngLED colon.pngLED digit 1.pngLED digit 8.pngLED am.png

Vertical clocks[edit]

Wrapping the clock in a <div> with the same width as the segments will make it vertical. Borders work as normal. The vertical clock isn't displayed to prevent inconvenience but this code works perfectly.

<div style="float:right; width:40px; border:5px solid black"> {{Digital clock}} </div>

Random colors[edit]

Parser magic can be used to pick a random color each time the page is generated. Use the following code to pick random clors from the colors specified. Note - You can change the colors given according to your preference. This code will produce the clock given below. {{Digital clock |color = {{#switch:{{#expr:{{#time:U}} mod 6}} |0=red |1=orange |2=lime |3=yellow |4=cyan |5=magenta}}

LED digit 0.pngLED digit 6.pngLED colon.pngLED digit 1.pngLED digit 8.png

See also[edit]


  • {{Currentdate}} – Time, day of week, and date in MDY format
  • {{Date}} – Date in chosen format
  • {{DATE}} – Month and year, prefixed by "date=" (for use with templates through substitution)
  • {{Now}} – Same as {{Currentdate}} but in a sentence
  • {{Plain now}} – Date in DMY format, and time
  • {{Right now}} – Blue banner with time and current number of Wikipedia articles
  • {{Right now (User message)}} – Orange banner with time and current number of Wikipedia articles
  • {{TODAY}} – Date in DMY