/*********************************************** * Local Time script- © Dynamic Drive (http://www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit http://www.dynamicdrive.com/ for this script and 100s more. ***********************************************/ /* In start() function on the top of the html page is the following: window.onload=showLocalTime. */ var weekdaystxt=["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] var weekdaystxtshort=["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] var monthstxt=["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] var monthstxtshort=["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] function showLocalTime(container, servermode, offsetMinutes, targetdate11, targetdate12, displayversion) { if (!document.getElementById || !document.getElementById(container)) return this.container=document.getElementById(container) this.displayversion=displayversion var servertimestring=(servermode=="server-php")? 'November 26, 2024 15:48:35' : (servermode=="server- ssi")? '' : '<%= Now() %>' this.localtime=this.serverdate=new Date(servertimestring) this.localtime.setTime(this.serverdate.getTime()+offsetMinutes*60*1000) //add user offset to server time this.targetdate11=new Date(targetdate11) this.targetdate12=new Date(targetdate12) this.targetdate12= this.targetdate12 - 1000*60*60 //For being able to have targetdate12 according to official dst ending hour. this.daylightsaving = 0 if (this.targetdate11 < this.localtime && this.targetdate12 > this.localtime){ (this.daylightsaving = 1);} this.localtime.setTime(this.serverdate.getTime()+this.daylightsaving*60*60*1000) this.updateTime() this.updateContainer() } showLocalTime.prototype.updateTime=function(){ var thisobj=this this.localtime.setSeconds(this.localtime.getSeconds()+1) setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second } showLocalTime.prototype.updateContainer=function() { var thisobj=this var date=this.localtime.getDate() var monthofyear=monthstxt[this.localtime.getMonth()] var monthofyearshort=monthstxtshort[this.localtime.getMonth()] var year=this.localtime.getFullYear() var hour=this.localtime.getHours() var minutes=this.localtime.getMinutes() var seconds=this.localtime.getSeconds() var dayofweek=weekdaystxt[this.localtime.getDay()] var dayofweekshort=weekdaystxtshort[this.localtime.getDay()] // if (this.displayversion=="long") { // this.container.innerHTML=dayofweek+", "+date+" "+monthofyear+" "+year+", "+format24(hour, 1)+":"+format24(minutes)+":"+format24(seconds) // } // else if (this.displayversion=="short") { // this.container.innerHTML=format24(hour, 1)+":"+format24(minutes)+" ("+dayofweekshort+")" // } if (this.displayversion=="worldclock12") { this.container.innerHTML=dayofweekshort+" "+format12(hour, 1)+":"+format12(minutes)+" "+format12ampm(hour) } if (this.displayversion=="worldclock24") { this.container.innerHTML=dayofweekshort+" "+format24(hour, 1)+":"+format24(minutes) } if (this.displayversion=="utc12") { this.container.innerHTML=dayofweekshort+", "+date+" "+monthofyearshort+" "+year+", "+format12(hour, 1)+":"+format12(minutes)+":"+format12(seconds)+" "+""+format12ampm(hour)+""; } if (this.displayversion=="utc24") { this.container.innerHTML=dayofweekshort+", "+date+" "+monthofyearshort+" "+year+", "+format24(hour, 1)+":"+format24(minutes)+":"+format24(seconds); } // if (this.displayversion=="clock_line_1") { // this.container.innerHTML=format24(hour, 1)+":"+format24(minutes)+":"+format24(seconds) // } // if (this.displayversion=="clock_line_2") { // this.container.innerHTML=dayofweekshort+" "+date+" "+monthofyearshort+" "+year // } if (this.displayversion=="gmtpage_line1_12") { this.container.innerHTML=format12(hour, 1)+":"+format12(minutes)+":"+format12(seconds)+" "+format12ampm(hour); } if (this.displayversion=="gmtpage_line1_24") { this.container.innerHTML=format24(hour, 1)+":"+format24(minutes)+":"+format24(seconds) } if (this.displayversion=="gmtpage_line2") { this.container.innerHTML=dayofweekshort+" "+date+" "+monthofyearshort+" "+year } setTimeout(function() { thisobj.updateContainer()}, 1000) //update container every second } function format24(num, isHour) { return (num<=9)? "0"+num : num//if this is minute or sec field } function format12(num, isHour) { if (typeof isHour!="undefined") { //if this is the hour field var hour=(num>12)? num-12 : num return (hour==0)? 12 : hour } return (num<=9)? "0"+num : num//if this is minute or sec field } function format12ampm(num) { var ampm = (num >= 12)? "pm" : "am"; return ampm; } // Server_dst_correction var uk111 = '27 March, 2011 01:00:00'; var uk112 = '30 October, 2011 02:00:00'; var uk121 = '25 March, 2012 01:00:00'; var uk122 = '28 October, 2012 02:00:00'; var uk131 = '31 March, 2013 01:00:00'; var uk132 = '27 October, 2013 02:00:00'; var uk141 = '30 March, 2014 01:00:00'; var uk142 = '26 October, 2014 02:00:00'; var uk151 = '29 March, 2015 01:00:00'; var uk152 = '25 October, 2015 02:00:00'; var uk161 = '27 March, 2016 01:00:00'; var uk162 = '30 October, 2016 02:00:00'; var uk171 = '26 March, 2017 01:00:00'; var uk172 = '29 October, 2017 02:00:00'; var uk181 = '25 March, 2018 01:00:00'; var uk182 = '28 October, 2018 02:00:00'; var uk191 = '31 March, 2019 01:00:00'; var uk192 = '27 October, 2019 02:00:00'; // next decade var uk201 = '29 March, 2020 01:00:00'; var uk202 = '25 October, 2020 02:00:00'; var uk211 = '28 March, 2021 01:00:00'; var uk212 = '31 October, 2021 02:00:00'; var uk221 = '27 March, 2022 01:00:00'; var uk222 = '30 October, 2022 02:00:00'; var uk231 = '26 March, 2023 01:00:00'; var uk232 = '29 October, 2023 02:00:00'; var uk241 = '31 March, 2024 01:00:00'; var uk242 = '27 October, 2024 02:00:00'; var uk251 = '30 March, 2025 01:00:00'; var uk252 = '26 October, 2025 02:00:00'; var uk261 = '29 March, 2026 01:00:00'; var uk262 = '25 October, 2026 02:00:00'; var uk271 = '28 March, 2027 01:00:00'; var uk272 = '31 October, 2027 02:00:00'; var uk281 = '26 March, 2028 01:00:00'; var uk282 = '29 October, 2028 02:00:00'; var uk291 = '25 March, 2029 01:00:00'; var uk292 = '28 October, 2029 02:00:00'; var UKservertimestring='November 26, 2024 15:48:35'; this.UKlocaltime=this.UKserverdate=new Date(UKservertimestring); this.uk111=new Date(uk111); this.uk112=new Date(uk112); this.uk112= this.uk112 - 1000*60*60; //to use official dst ending hour. this.uk121=new Date(uk121); this.uk122=new Date(uk122); this.uk122= this.uk122 - 1000*60*60; this.uk131=new Date(uk131); this.uk132=new Date(uk132); this.uk132= this.uk132 - 1000*60*60; this.uk141=new Date(uk141); this.uk142=new Date(uk142); this.uk142= this.uk142 - 1000*60*60; this.uk151=new Date(uk151); this.uk152=new Date(uk152); this.uk152= this.uk152 - 1000*60*60; this.uk161=new Date(uk161); this.uk162=new Date(uk162); this.uk162= this.uk162 - 1000*60*60; this.uk171=new Date(uk171); this.uk172=new Date(uk172); this.uk172= this.uk172 - 1000*60*60; this.uk181=new Date(uk181); this.uk182=new Date(uk182); this.uk182= this.uk182 - 1000*60*60; this.uk191=new Date(uk191); this.uk192=new Date(uk192); this.uk192= this.uk192 - 1000*60*60; // next decade this.uk201=new Date(uk201); this.uk202=new Date(uk202); this.uk202= this.uk202 - 1000*60*60; this.uk211=new Date(uk211); this.uk212=new Date(uk212); this.uk212= this.uk212 - 1000*60*60; this.uk221=new Date(uk221); this.uk222=new Date(uk222); this.uk222= this.uk222 - 1000*60*60; this.uk231=new Date(uk231); this.uk232=new Date(uk232); this.uk232= this.uk232 - 1000*60*60; this.uk241=new Date(uk241); this.uk242=new Date(uk242); this.uk242= this.uk242 - 1000*60*60; this.uk251=new Date(uk251); this.uk252=new Date(uk252); this.uk252= this.uk252 - 1000*60*60; this.uk261=new Date(uk261); this.uk262=new Date(uk262); this.uk262= this.uk262 - 1000*60*60; this.uk271=new Date(uk271); this.uk272=new Date(uk272); this.uk272= this.uk272 - 1000*60*60; this.uk281=new Date(uk281); this.uk282=new Date(uk282); this.uk282= this.uk282 - 1000*60*60; this.uk291=new Date(uk291); this.uk292=new Date(uk292); this.uk292= this.uk292 - 1000*60*60; var correc = 0; if ((this.uk111 < this.UKlocaltime && this.uk112 > this.UKlocaltime) || (this.uk121 < this.UKlocaltime && this.uk122 > this.UKlocaltime) || (this.uk131 < this.UKlocaltime && this.uk132 > this.UKlocaltime) || (this.uk141 < this.UKlocaltime && this.uk142 > this.UKlocaltime) || (this.uk151 < this.UKlocaltime && this.uk152 > this.UKlocaltime) || (this.uk161 < this.UKlocaltime && this.uk162 > this.UKlocaltime) || (this.uk171 < this.UKlocaltime && this.uk172 > this.UKlocaltime) || (this.uk181 < this.UKlocaltime && this.uk182 > this.UKlocaltime) || (this.uk191 < this.UKlocaltime && this.uk192 > this.UKlocaltime) || (this.uk201 < this.UKlocaltime && this.uk202 > this.UKlocaltime) || (this.uk211 < this.UKlocaltime && this.uk212 > this.UKlocaltime) || (this.uk221 < this.UKlocaltime && this.uk222 > this.UKlocaltime) || (this.uk231 < this.UKlocaltime && this.uk232 > this.UKlocaltime) || (this.uk241 < this.UKlocaltime && this.uk242 > this.UKlocaltime) || (this.uk251 < this.UKlocaltime && this.uk252 > this.UKlocaltime) || (this.uk261 < this.UKlocaltime && this.uk262 > this.UKlocaltime) || (this.uk271 < this.UKlocaltime && this.uk272 > this.UKlocaltime) || (this.uk281 < this.UKlocaltime && this.uk282 > this.UKlocaltime) || (this.uk291 < this.UKlocaltime && this.uk292 > this.UKlocaltime)) {correc = 0;}