VOOZH about

URL: https://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Time

⇱ Wikipedia:WikiProject User scripts/Scripts/Time - Wikipedia


Jump to content
From Wikipedia, the free encyclopedia
//<pre><nowiki>
// Add date and time to your monobook "personal menu" list at the very top of the page.
// Created by [[User:Mathwiz2020]]
// Indicate where you would like the time to appear:
// 1 is first (before username), 2 is second (before talk link), ... 7 is last (after log out link)
insertBeforeNum=7;
// Do NOT edit below this line unless you're experiened in javascript
insertBeforeArr=newArray("","pt-userpage","pt-mytalk","pt-preferences","pt-watchlist","pt-mycontris","pt-logout","");
insertBefore=insertBeforeArr[insertBeforeNum];
functionmakeTime()
{
varli=document.createElement('li');
li.id='pt-time';
varmySpan=document.createElement('span');
mySpan.appendChild(document.createTextNode('date and time'));
li.appendChild(mySpan);
if(insertBefore)
{
varbefore=document.getElementById(insertBefore);
before.appendChild(li,before);
}
else// append to end (right) of list
{
document.getElementById('pt-logout').parentNode.appendChild(li);
}
getTime();
}
if(window.addEventListener)window.addEventListener('load',makeTime,false);
elseif(window.attachEvent)window.attachEvent('onload',makeTime);
functiongetTime()
{
vartime=newDate();
vardate=time.getUTCDate();
varmonths='Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
month=months[time.getUTCMonth()];
varyear=time.getUTCFullYear();
varhours='0'+time.getUTCHours();
hours=hours.substr(hours.length-2,hours.length);
varminutes='0'+time.getUTCMinutes();
minutes=minutes.substr(minutes.length-2,minutes.length);
varseconds='0'+time.getUTCSeconds();
seconds=seconds.substr(seconds.length-2,seconds.length);
varcurTime=hours+":"+minutes+":"+seconds+", "+date+" "+month+" "+year+" (UTC)";
datePlace=document.getElementById('pt-time').childNodes[0].childNodes[0];
datePlace.replaceData(0,datePlace.length,curTime);
doTime=window.setTimeout("getTime()",1000);
}
//</nowiki></pre>