/////////////////////////////////////////////////////////// // "Live Clock" script - Version 2.6 // By Mark Plachetta (astroboy@zip.com.au) // // Get the latest version from: // http://www.zip.com.au/~astroboy/liveclock/ // // Based on the original script: "Upper Corner Live Clock" // available at: // - Dynamic Drive (http://www.dynamicdrive.com) // - Website Abstraction (http://www.wsabstract.com) // ======================================================== // CHANGES TO ORIGINAL SCRIPT: // - Gave more flexibility in positioning of clock // - Added date construct // - User configurable // ======================================================== // This script is available free of charge, see the website // for more information. Please check the website before // e-mailing for help. /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////// CONFIGURATION ///////////////////////////// // Set the clock's font face: var LC_Font_Face = "Arial"; // Set the clock's font size (in point): var LC_Font_Size = "9"; // Set the clock's font color: var LC_Font_Color = "#000000"; // Set the clock's background color: var LC_Back_Color = "#ffffcc"; // Set any extra HTML to go either side the clock here: var LC_OpenTags = " "; var LC_CloseTags = ""; // Set the width of the clock (in pixels): var LC_Width = 140; //133 var HEIGHT = 30; //24 // Display the time in 24 or 12 hour time? // 0 = 24, 1 = 12 var LC_12_Hour = 01 ; // How often do you want the clock updated? // 0 = Never, 1 = Every Second, 2 = Every Minute // If you pick 0 or 2, the seconds will not be displayed var LC_Update = 1; // Date Options: // 0 = No Date, 1 = dd/mm/yy, 2 = mm/dd/yy, 3 = DDDD MMMM, 4 = DDDD MMMM YYYY var LC_DisplayDate = 1; // Abbreviate Day/Month names? // 0 = No, 1 = Yes; var LC_Abbrev = 0; // Your GMT Offset: // This will allow the clock to always be set to your local // time, rather than that of the visitor's system clock. // Set to "" to disable this feature. var LC_GMT = ""; // Note that this does not take into account daylight savings. // You should add 1 to your GMT offset if daylight savings is // currently active in your area. var server_time = new Date('May 16 13:47:57 2008'); var current_time = new Date(); var time_offset= server_time-current_time; /////////////// END CONFIGURATION ///////////////////////// /////////////////////////////////////////////////////////// // Globals: var LC_HTML; var LC_AMPM; // The following arrays contain data which is used in the // clock's date function. var LC_DaysOfWeek = new Array(7); LC_DaysOfWeek[0] = "Sunday"; LC_DaysOfWeek[1] = "Monday"; LC_DaysOfWeek[2] = "Tuesday"; LC_DaysOfWeek[3] = "Wednesday"; LC_DaysOfWeek[4] = "Thursday"; LC_DaysOfWeek[5] = "Friday"; LC_DaysOfWeek[6] = "Saturday"; var LC_MonthsOfYear = new Array(12); LC_MonthsOfYear[0] = (LC_Abbrev) ? "Jan" : "January"; LC_MonthsOfYear[1] = (LC_Abbrev) ? "Feb" : "February"; LC_MonthsOfYear[2] = (LC_Abbrev) ? "Mar" : "March"; LC_MonthsOfYear[3] = (LC_Abbrev) ? "Apr" : "April"; LC_MonthsOfYear[4] = (LC_Abbrev) ? "May" : "May"; LC_MonthsOfYear[5] = (LC_Abbrev) ? "Jun" : "June"; LC_MonthsOfYear[6] = (LC_Abbrev) ? "Jul" : "July"; LC_MonthsOfYear[7] = (LC_Abbrev) ? "Aug" : "August"; LC_MonthsOfYear[8] = (LC_Abbrev) ? "Sep" : "September"; LC_MonthsOfYear[9] = (LC_Abbrev) ? "Oct" : "October"; LC_MonthsOfYear[10] = (LC_Abbrev) ? "Nov" : "November"; LC_MonthsOfYear[11] = (LC_Abbrev) ? "Dec" : "December"; // This array controls how often the clock is updated, // based on your selection in the configuration. var LC_ClockUpdate = new Array(3); LC_ClockUpdate[0] = 0; LC_ClockUpdate[1] = 1000; LC_ClockUpdate[2] = 60000; // Basic browser detection: var LC_IE = (document.all) ? 1 : 0; var LC_NS = (document.layers) ? 1 : 0; var LC_N6 = (window.sidebar) ? 1 : 0; var LC_Old = (!LC_IE && !LC_NS && !LC_N6) ? 1 : 0; // For Version 4+ browsers, write the appropriate HTML to the // page for the clock, otherwise, attempt to write a static // date to the page. var LC_StartTags = (LC_NS) ? '
' : ''; // if (LC_IE || LC_N6) { LC_ClockTags = '
'; } // else if (LC_NS) { LC_ClockTags = ''; } if (LC_IE || LC_N6) { LC_ClockTags = '
'; } else if (LC_NS) { LC_ClockTags = ''; } var LC_EndTags = (LC_NS) ? '
' : ''; if (!LC_Old) { document.write(LC_StartTags+LC_ClockTags+LC_EndTags); } else { show_clock(); } onload = clock_init; function clock_init() { if (!LC_Old) { show_clock(); } // If you have any other scripts which use the "onload" event, // call them here: } // The main part of the script: function show_clock() { // Get all our date variables: var time = new Date(); time.setTime(time.getTime()+time_offset); if (LC_GMT) { var offset = time.getTimezoneOffset(); if (parseInt(navigator.appVersion) == 4 && LC_NS) { offset += 60; } if (navigator.appVersion.indexOf('MSIE 3') != -1) { offset = offset * (-1); } time.setTime(time.getTime() + offset*60000); time.setTime(time.getTime() + LC_GMT*3600000); } var day = time.getDay(); var mday = time.getDate(); var month = time.getMonth(); var hours = time.getHours(); var minutes = time.getMinutes(); var seconds = time.getSeconds(); var year = time.getYear(); // Fix the "year" variable for Y2K: if (year < 1900) { year += 1900; } // Add appropriate "th" if displaying full date: if (LC_DisplayDate >= 3) { mday += ""; abbrev = "th"; if (mday.charAt(mday.length-2) != 1) { if (mday.charAt(mday.length-1) == 1) { abbrev = "st"; } else if (mday.charAt(mday.length-1) == 2) { abbrev = "nd"; } else if (mday.charAt(mday.length-1) == 3) { abbrev = "rd"; } } mday += abbrev; } // Set up the hours for either 24 or 12 hour display: if (LC_12_Hour) { LC_AMPM = "AM"; if (hours >= 12) { LC_AMPM = "PM"; hours -= 12; } if (hours == 0) { hours = 12; } } if (hours <= 9) { hours = '0'+hours; } if (minutes <= 9) { minutes = '0'+minutes; } if (seconds <= 9) { seconds = '0'+seconds; } if (mday<=9) {mday = "0"+mday;} month++; if (month<=9) {month = "0"+month;} // This is the actual HTML of the clock. If you're going to play around // with this, be careful to keep all your quotations in tact. // LC_HTML = ''; LC_HTML = ''; LC_HTML += LC_OpenTags; LC_HTML += '
'+LC_DaysOfWeek[day]+'(CET)
'; LC_HTML += ''+(month)+'/'+mday+'/'+year+''; LC_HTML += hours+':'+minutes; if (LC_Update == 1) { LC_HTML += ':'+seconds; } if (LC_12_Hour) { LC_HTML += ' '+LC_AMPM; } LC_HTML += '
'; LC_HTML += LC_CloseTags; LC_HTML += '
'; if (LC_Old) { document.write(LC_HTML); return; } // Write the clock to the layer: if (LC_NS) { clockpos = document.layers["ClockPosNS"]; liveclock = clockpos.document.layers["LiveClockNS"]; liveclock.document.write(LC_HTML); liveclock.document.close(); } else if (LC_IE) { LiveClockIE.innerHTML = LC_HTML; } else if (LC_N6) { document.getElementById("LiveClockIE").innerHTML = LC_HTML; } if (LC_Update != 0) { setTimeout("show_clock()",LC_ClockUpdate[LC_Update]); } }