coding help
Icon Star Yellow LR26
Only a wiki's admins can enable this feature.
Only people with Administrator privileges can add features to a wiki's JavaScript.

Countdowns are used to count down the days to a day or event of your choice. On wikis, they can be added using imported JavaScript.

Only wiki admins can add JavaScript to a wiki.

Importing JavaScript

To enable JavaScript:

  1. Get JavaScript enabled on the wiki you admin. To do this, submit a request with Fandom. Wait until they approve it.
  2. Go to your admin dashboard.
  3. Click MediaWiki:ImportJS.
  4. Click "Create" or "Edit source."
  5. Add the following code:
// Enables countdowns
dev:Countdown/code.js

(While comments aren't technically required, it's nice to explain what you're doing.)

Using the countdown

Once you've installed the countdown JavaScript, you can use HTML to set it up. Here's some example code:

<span class="countdown" style="display:none;">It has been <span class="countdowndate">January 01 2000 00:00:00</span> since the 21st century began.</span>

Here are our elements:

  1. Outer span: Our outer span needs a class of "countdown" so the JavaScript will identify it. Set the display to none. (This will get overridden.)
  2. Contents: Wrap your sentence(s) in the span tag.
  3. Inner span: Wrap your target date in a span with the class "countdowndate." This tells the code which date to use.

Output:

Countdown

You can count down to a specific date.

<span class="countdown" style="display:none;">Only <span class="countdowndate">January 01 2030 00:00:00</span> until the new year in 2030!</span>

And we get:


Counting up

You can also count up to see how much time has passed since a certain time. For example:

<span class="countdown" style="display:none;">I have been here for <span class="countdowndate">December 27 2022 05:15</span>!

See also

External links