User talk:Poke: Difference between revisions

(→‎Timer: new section)
Line 65: Line 65:


Would you be able to show me how to get a timer (via wiki coding) that counts down by second, minutes and hours? Please reply on my talk page, thanks.--'''[[User:MysteryHeff?|<span style="color:Blue">MysteryHeff?</span>]]''' [[User Talk:MysteryHeff?|<small><sup><span style="color:Orange">TALK</span></sup></small>]] 11:32, 8 January 2009 (UTC)
Would you be able to show me how to get a timer (via wiki coding) that counts down by second, minutes and hours? Please reply on my talk page, thanks.--'''[[User:MysteryHeff?|<span style="color:Blue">MysteryHeff?</span>]]''' [[User Talk:MysteryHeff?|<small><sup><span style="color:Orange">TALK</span></sup></small>]] 11:32, 8 January 2009 (UTC)
:It's not possible via wiki-code to get a live timer that counts down, similar to the UTC clock we have at the top now. MediaWiki doesn't support javascript commands in-line, so the only thing you can get via wiki-code is a static timer that updates when you reload the page. The easiest way to do that is using the #time parser function and some calculating. For example to get the seconds until next year (yay!), we do: <code><nowiki>{{ #expr: {{ #time: U | 01.01.2010 00:00 }} - {{ #time: U }} }}</nowiki></code> and get <tt>{{ #expr: {{ #time: U | 01.01.2010 00:00 }} - {{ #time: U }} }}</tt> seconds as a result.
:Sadly the result that is given by that is cached, as every content on MediaWikis; that means that the time that is displayed there won't update whenever you visit the page but whenever the cache is renewed (one way to do that is purging the page, for example by clicking the UTC clock), and there is no way to prevent that. <span style="font-size: 85%;">[[User:Poke|poke]] | [[User talk:Poke|talk]]</span> 16:33, 10 January 2009 (UTC)
17

edits