Hello there! We are conducting a survey to better understand the user experience in making a first edit. If you have ever made an edit on Gamepedia, please fill out the survey. Thank you!

Extension:Countdown

From Gamepedia Help Wiki
Jump to: navigation, search
Countdown
Version 1.0
Author(s) Cameron Chunn
Description
Allows the placement of a countdown ticker.

Countdown is an extension that allows users place a countdown ticker on wiki pages.

Parameters[edit | edit source]

Name Desc
time The time we are counting down to. Accepts anything that PHP's strtotime function can accept.
name An identifier for this countdown. If not provided, a random string will be generated. (this is just used so multiple countdowns can exist on a page, and you probably don't have a reason to customize it unless you need to reference it in custom javascript)
finishmessage A message to display when the countdown is finished. This text will replace everything inside the countdown tag.

Usage[edit | edit source]

This example will show a countdown to a birthday.

<countdown time="03/26/2055 00:00:00" name="bday" finishmessage="Happy Birthday, Cchunn!">
Cchunn's Birthday is in: 
<D> Days, <H> hours, <M> minutes, <S> seconds.
</countdown>

Cchunn's Birthday is in: Days, hours, minutes, seconds.

Use with templates[edit | edit source]

The functionality can be expanded on a bit with the use of templates. Here is an example template used on the Exvious wiki:

<!-- Template:Countdown -->
<includeonly>
	{{#ifexpr: 
		{{#expr: ( {{#time: U | now -8 hours}} > {{#time: U | {{{end|01/01/01 00:00:00}}} }} ) }} 
		| '''{{{finished|}}}'''
		| {{#ifexpr: {{#expr: 
						( {{#time: U | now -8 hours}} > {{#time: U | {{{start|01/01/01 00:00:00}}} }} ) 
					  }} 
		| '''{{{text|}}} ends:''' {{#tag: countdown | '''<D> days, <H> hours, <M> minutes, <S> seconds.''' | time="{{{end|01/01/01 00:00:00}}} UTC-0800" }}
		| '''{{{text|}}} starts:''' {{#tag: countdown | '''<D> days, <H> hours, <M> minutes, <S> seconds.''' | time="{{{start|01/01/01 00:00:00}}} UTC-0800" }} }} 
	}}
</includeonly>
<noinclude>[[Category:Templates]]</noinclude>

The template can then be called to have a countdown to a "start" and then the countdown to an "end".

{{countdown
|text = Event
|finished = Event has ended.
|start    = 01/27/17 00:00:00
|end      = 02/02/17 23:59:59
}}

Using this template, if you are before the "start" you will see:

Event Starts: ''' 2 Days, 2 Hours, 2 Minutes, 2 Seconds '''

or if you are past the start but before the end:

Event Ends: ''' 2 Days, 2 Hours, 2 Minutes, 2 Seconds '''

or if you are past the end:

Event has ended.