Date and clock function
The display of a real-time date and clock is an optional settings under the theme settings. By default the date and time is displayed in a horizontal bar above your site header. The background colour of this clock bar is interchangable under the theme colour settings. The date and clock are floated to the right in a 299px wide container. Optionally you can insert Extra Content such as text, links or icons to the right hand side of your clock function.
Javascript is used to generate the real-time date and clock function. The code used is located within the theme javascript.js file and looks like this:
function clock() {
var digital = new Date();
var day=new Date();
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";
var date = digital.getDate();
var m=new Date();
var month=new Array(12);
month[0]="January";
month[1]="February";
month[2]="March";
month[3]="April";
month[4]="May";
month[5]="June";
month[6]="July";
month[7]="August";
month[8]="September";
month[9]="October";
month[10]="November";
month[11]="December";
var year = digital.getFullYear();
var hours = digital.getHours();
var minutes = digital.getMinutes();
var seconds = digital.getSeconds();
var amOrPm = "AM";
if (hours > 11) amOrPm = "PM";
if (hours > 12) hours = hours - 12;
if (hours == 0) hours = 12;
if (minutes <= 9) minutes = "0" + minutes;
if (seconds <= 9) seconds = "0" + seconds;
dispTime = ''+weekday[day.getDay()] + " " +date + " " +month[m.getMonth()] + " " +year + " " +hours + ":" + minutes + ":" + seconds + " " + amOrPm+'';
document.getElementById('dateTimeFunction').innerHTML = dispTime;
setTimeout("clock()", 1000);
}
If you are developing a website in another language other than English, you can change the day and month names to localised names by amending the code above, found in the javascript.js file. The fourth to bottom line of code represents the order in which the date and time is printed. This can be changed if required. If you are familiar with Javascript, then any of the above code can be changed to suit your requirements.