Full version: jsB@nk » Time » Clock » World Time Zone Displayer
URL: https://www.javascriptbank.com/world-time-zone-displayer.html
Your visitors are from over the world? And you worry that they do know the best time to contact you? Let use this JavaScript code, may associate with some GMT zone script, to show your current timezone and your visitors what time that would be in their time zone.
Full version: jsB@nk » Time » Clock » World Time Zone Displayer
URL: https://www.javascriptbank.com/world-time-zone-displayer.html
<script type="text/javascript"><!--// Created by: William and Mari Bontrager :: http://willmaster.com/// Copyright 1999, 2000 by William and Mari Bontrager.// See complete instructions in the article "Easy Time // Zone Offset Calculator" in WillMaster Possibilities // issue # 46: http://willmaster.com/possibilities/archives/here_offset = 300;// The above number must be changed to the number of minutes // difference between your time and UT during STANDARD TIME // -- not Daylight Savings Time. If you are in UT, (the // same time zone as Greenwich, England), this number // will be 0 (zero). If your time is later than UT (east // of Greenwich, England), the number is negative. // Otherwise, the number is positive.// NOTE: To calculate the number automatically, go to // http://willmaster.com/possibilities/demo/eztzoffset.htmlDST_month_start = 0;// If your geographical area observes daylight savings time, // the above number represents the month the period begins. // Otherwise, the number is 0 (zero).DST_day_start = 0;// If your geographical area observes daylight savings time, // the above number represents day of the month the period // begins. Otherwise, the number is 0 (zero).DST_month_end = 0;// If your geographical area observes daylight savings time, // the above number represents the month the period ends. // Otherwise, the number is 0 (zero).DST_day_end = 0;// If your geographical area observes daylight savings time, // the above number represents day of the month the period // ends. Otherwise, the number is 0 (zero).clocktype = 12;// The above number must be either 12 or 24. Use 12 if you // want a 12-hour clock with "AM" or "PM" appended to the // time. Use 24 if you want a 24-hour clock.// NOTE: What you specify here is the default. You can change // this value right before you use a function.here_appt_weekday = 2;// The day of the week in your time zone that you want // calculated into your visitor's time zone. Use a // number 1-7: 1=Sunday 2=Monday 3=Tuesday // 4=Wednesday 5=Thursday 6=Friday 7=Saturday// NOTE: What you specify here is the default. You can change // this value right before you use a function.here_appt_hour = 10;// The hour in your time zone that you want calculated into // your visitor's time zone. Use 12 for noon and 0 for midnight.// NOTE: What you specify here is the default. You can change // this value right before you use a function.here_appt_minute = 27;// The number of minutes after the hour in your time zone // that you want calculated into your visitor's time zone.// NOTE: What you specify here is the default. You can change // this value right before you use a function.here_appt_ampm = 'AM';// If the above appt_hour and appt_minute is before noon, // use 'AM', otherwise use 'PM'. If your clocktype // variable (above) is 24, use 'AM';// NOTE: What you specify here is the default. You can change // this value right before you use a function.// NOTE: The above appt_... variables must have values assigned // to them whether or not you plan to calculate a specific // time for your visitor's time zone.disp_dow = 'yes';// Shall time displays include the day of the week ('yes' or 'no')?// NOTE: What you specify here is the default. You can change // it right before you use a function.// No other customizations are required.can_use_this = false;if(parseInt(navigator.appVersion) >= 4) { can_use_this = true; }vtime = new Date();if(DST_month_start > 0) {var b = false;var m = vtime.getMonth();var d = vtime.getDate();DST_month_start--;DST_month_end--;if((m > DST_month_start) && (m < DST_month_end)) { b = true; }else{if((m == DST_month_start) && (d >= DST_day_start)) { b = true; }if((m == DST_month_end) && (d <= DST_day_end)) { b = true; }}if(b == true) { here_offset -= 60; }}Diff = vtime.getTimezoneOffset() - here_offset;weekdays=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");if(! weekdays) { can_use_this = 0; }function get_future() {if(can_use_this == false) { return ''; }var apm = 'AM';var rs = '';if((clocktype == 12) && (here_appt_ampm == 'PM')) { here_appt_hour += 12; }b = new Date(vtime.getYear(),1,1,here_appt_hour,here_appt_minute,0);var t = 0;if(here_appt_weekday > 0){var tt = here_appt_weekday - 1;if(tt != b.getDay()) { t = tt - b.getDay(); }}if(t != 0) { b.setTime(Number(b) + (1000 * 60 * 60 * 24 * t)); }b.setTime(Number(b) - (Diff * 60000));var nowweekday = b.getDay();var hr = b.getHours();if(clocktype == 12){if(hr > 11) { apm = 'PM'; }if(hr > 12) { hr -= 12; }}rs = hr + ':';if(b.getMinutes() < 10) { rs += '0'; }rs += b.getMinutes();if(clocktype == 12) { rs += ' ' + apm; }if(here_appt_weekday > 0) { rs += ', ' + weekdays[b.getDay()]; }return rs;}function get_current(s) {if(can_use_this == false) { return ''; }var apm = 'AM';var rs = '';if((s == 'here') || (s == 'Here') || (s == 'HERE')){htime = new Date();htime.setTime(Number(vtime) + (Diff * 60000));var hr = htime.getHours();if(clocktype == 12){if(hr > 11) { apm = 'PM'; }if(hr > 12) { hr -= 12; }}rs = hr + ':';if(htime.getMinutes() < 10) { rs += '0'; }rs += htime.getMinutes(); if(clocktype == 12) { rs += ' ' + apm; }if((disp_dow == 'yes') || (disp_dow == 'Yes') || (disp_dow == 'YES')){ rs += ', ' + weekdays[htime.getDay()]; }}else{var hr = vtime.getHours();if(clocktype == 12){if(hr > 11) { apm = 'PM'; }if(hr > 12) { hr -= 12; }}rs = hr + ':';if(vtime.getMinutes() < 10) { rs += '0'; }rs += vtime.getMinutes();if(clocktype == 12) { rs += ' ' + apm; }if((disp_dow == 'yes') || (disp_dow == 'Yes') || (disp_dow == 'YES')){ rs += ', ' + weekdays[vtime.getDay()]; }}return rs;}//--></script>
Our current time » <script language="JavaScript"><!-- disp_dow = 'no';document.write(get_current('here'));//--></script><br>Your current time » <script language="JavaScript"><!-- disp_dow = 'no';document.write(get_current('visitor'));//--></script><br />Please be considerate when you call.