Forum:Countdown script

I found this script for a timer, but it uses html. How can I convert it so that it would work in a div or span tag here, without that input form?

I'm trying to modify it a bit, but I'm stuck on importing it... -- 00:25, April 24, 2011 (UTC)


 * Change  to  . Then, you can use.
 * Copy this to your wikia.js and common.js

So http://yourwikiname.wikia.com/index.php?title=MediaWiki:Common.js&action=edit Then just import this template I made here And follow the documentation --vegeance 02:07, April 24, 2011 (UTC)


 * That was helpful !


 * Thanks Monchoman, that worked :)


 * Splarka's code doesn't do exactly what I need and is too complicated for me (I'm trying to find the simplest solution that is the closest to what I need, and work from there). -- 10:33, April 24, 2011 (UTC)

I grabbed the clock example from w3schools instead, and managed to modify it so that it takes the UTC time and displays a clock or a 24-hour countdown timer (which can be easily adapted for various needs).

Pretty cool :) Here's the code I ended up with:

function startTime { var today=new Date; var h=today.getUTCHours; var m=today.getUTCMinutes; var s=today.getUTCSeconds; var s1=(s!=00)?60-s:s; var m1=(m!=00)?60-m:m; var h1=(24 - (h-11)) % 24; // <--11 is used as a time zone offset

// add a zero in front of numbers<10 m=checkTime(m); s=checkTime(s); m1=checkTime(m1); s1=checkTime(s1); document.getElementById('Clock').innerHTML = h - 11 + ":" + m + ":" + s; document.getElementById('CountdownTimer').innerHTML = h1 + ":" + m1 + ":" + s1; t=setTimeout('startTime',500); }

function checkTime(i) { if (i<10) { i="0" + i;  } return i; }

addOnloadHook(startTime); Clock can be displayed with   , and countdown with    . Example page. -- 14:30, April 24, 2011 (UTC)