visitor Posted October 28, 2009 Share Posted October 28, 2009 Hi I've got the below script which works almost perfect... the only thing I'd like to have changed is an automatic update on summer and wintertime. Does anyone know how this can be done, please? <table style="width: 100%; height: 100%;"> <tr> <td valign="middle" align="center"> <script language="javascript1.2"> // get the date and change it to GMT string var date = new Date(); var timegmt = date.toGMTString(); // split the GMT string at spaces time_string = timegmt.split(' '); // assign variables week = time_string[0]; day = time_string[1]; mon = time_string[2]; year = time_string[3]; hms = time_string[4]; // split the time part on colon hms_string = hms.split(':'); // assign variables var hour = hms_string[0] - 0; var min = hms_string[1]; // convert day-of-week variables to numbers if (week == 'Sun,') { week = 1 } if (week == 'Mon,') { week = 2 } if (week == 'Tue,') { week = 3 } if (week == 'Wed,') { week = 4 } if (week == 'Thu,') { week = 5 } if (week == 'Fri,') { week = 6 } if (week == 'Sat,') { week = 7 } // fix mac version communicator bug function checkOS() { if (navigator.appVersion.indexOf("Mac") > 0) return "Macintosh"; else return "other"; } var check = checkOS(); if (check == "Macintosh") { week -= 1 } // make array for days of week weekly = new Array("Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); // assign +- hour for New York var ny_hour = hour - 4; var ny_week = week; var ny_ampm = " a.m."; if (ny_hour < 0) { ny_hour += 24 ny_week -= 1 } if (ny_hour > 11) { ny_ampm = " p.m." } if (ny_hour > 12) { ny_hour -= 12 } if (ny_hour == 0) { ny_hour = 12 } // assign +- hours for London var ldn_hour = hour + 1; var ldn_week = week; var ldn_ampm = " a.m."; if (ldn_hour > 24) { ldn_hour -= 24 ldn_week += 1 } if (ldn_hour > 11) { ldn_ampm = " p.m." } if (ldn_hour > 12) { ldn_hour -= 12 } if (ldn_hour == 0) { ldn_hour = 12 } // assign +- hours for Zurich var zrh_hour = hour + 2; var zrh_week = week; var zrh_ampm = " a.m."; if (zrh_hour > 24) { zrh_hour -= 24 zrh_week += 1 } if (zrh_hour > 11) { zrh_ampm = " p.m." } if (zrh_hour > 12) { zrh_hour -= 12 } if (zrh_hour == 0) { zrh_hour = 12 } // assign +- hours for Singapore var sng_hour = hour + 8; var sng_week = week; var sng_ampm = " a.m."; if (sng_hour > 24) { sng_hour -= 24 sng_week += 1 } if (sng_hour > 11) { sng_ampm = " p.m." } if (sng_hour > 12) { sng_hour -= 12 } if (sng_hour == 0) { sng_hour = 12 } // assign +- hours for Auckland var akl_hour = hour + 12; var akl_week = week; var akl_ampm = " a.m."; if (akl_hour > 24) { akl_hour -= 24 akl_week += 1 } if (akl_hour > 11) { akl_ampm = " p.m." } if (akl_hour > 12) { akl_hour -= 12 } if (akl_hour == 0) { akl_hour = 12 } //--> </script> <script language="javascript1.2"> <!-- hideme var loc_hour = date.getHours(); var loc_ampm = " a.m."; if (loc_hour > 11) { loc_ampm = " p.m." } if (loc_hour > 12) { loc_hour -= 12 } document.write('<font size=2>Note: Your local time is </font>'); document.write(loc_hour + ':' + min + loc_ampm); document.write('<font size=2>Times listed in the following table are based on your computer\'s time. If your computer\'s clock is wrong, so is this table.</font>'); //--> </script> <center><table CELLSPACING=50 > <tr> <td ALIGN=CENTER VALIGN=TOP><script language="javascript1.2"> <!-- hide it //--> </script> </td> <td ALIGN=CENTER VALIGN=TOP><script language="javascript1.2"> <!-- hide it document.write('NEW YORK<br>'); document.write(weekly[ny_week] + '<br>'); document.write(ny_hour + ':' + min + ny_ampm + '<br>'); //--> </script> </td> <td ALIGN=CENTER VALIGN=TOP><script language="javascript1.2"> <!-- hide it document.write('LONDON<br>'); document.write(weekly[ldn_week] + '<br>'); document.write(ldn_hour + ':' + min + ldn_ampm + '<br>'); //--> </script> </td> <td ALIGN=CENTER VALIGN=TOP><script language="javascript1.2"> <!-- hide it document.write('ZURICH<br>'); document.write(weekly[zrh_week] + '<br>'); document.write(zrh_hour + ':' + min + zrh_ampm + '<br>'); //--> </script> </td> <td ALIGN=CENTER VALIGN=TOP><script language="javascript1.2"> <!-- hide it document.write('SINGAPORE<br>'); document.write(weekly[sng_week] + '<br>'); document.write(sng_hour + ':' + min + sng_ampm + '<br>'); //--> </script> </td> <td ALIGN=CENTER VALIGN=TOP><script language="javascript1.2"> <!-- hide it document.write('AUCKLAND<br>'); document.write(weekly[akl_week] + '<br>'); document.write(akl_hour + ':' + min + akl_ampm + '<br>'); //--> </script> </td> </tr> </table> Thanks visitor Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 28, 2009 Share Posted October 28, 2009 like standard and daylight savings time Daylight Savings i am sure you can modify that to include DST(daylight savings time) in your own function Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.