Jump to content

hschonen

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

hschonen's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. try @unlink instead of unlink did it for me
  2. What you could do is make a [!--coloro:#33CC00--][span style=\"color:#33CC00\"][!--/coloro--]combination of php and javascript[!--colorc--][/span][!--/colorc--]. Use php to calculate the start and end dates of dst in different countries. Use the server time to calculate the standard gmt without dst. Then add or substract time to calculate the local time in any country. For countries with more timezones you'd have to add the states information as well. Not easy, but can be done. By declaring 7 different DST zones you pretty much got them all covered (you can extend to all but I wouldn't bother with a few days difference for just some countries). // Get today $eg_MKDate1 = mktime(); // Format date string $eg_Date1 = @date("Y-m-j", $eg_MKDate1); //Declare second sunday of march $day1 = "2007-03-04"; //Declare last sunday of march $day2 = "2006-03-26"; //Declare first sunday of april $day3 = "2006-04-02"; //Declare last sunday of september $day4 = "2006-09-24"; //Declare first sunday of october zoneDS $day5 = "2006-10-01"; //Declare second sunday of october $day6 = "2006-10-08"; //Declare last sunday of october zoneB $day7 = "2006-10-29"; //Declare last sunday of october zoneBS $day8 = "2006-10-29"; //Declare first sunday of april zoneBS $day9 = "2007-04-01"; //Declare DST zone A, from last sunday march to last sunday october, plus 1 hour //Declare DST zone B, from first sunday april to last sunday october, plus 1 hour //Declare DST zone BS, from last sunday october to first sunday april, plus 1 hour //Declare DST zone C, from second sunday october to second sunday march, plus 1 hour //Declare DST zone D, from last sunday march to last sunday september, plus 1 hour //Declare DST zone DS, from first sunday october to second sunday march, plus 1 hour //Declare DST zone no, from no daylight saving time $timez = $eg_Result1['Timezone']; $usertz = $eg_Result7['DST']; switch($usertz){ case "A": if($day2 < $eg_Date1 && $eg_Date1 < $day7) { $zone = "-60"; } else { $zone = "0"; } break; case "B": if($day3 < $eg_Date1 && $eg_Date1 < $day7) { $zone = "-60"; } else { $zone = "0"; } break; case "BS": if($day8 < $eg_Date1 && $eg_Date1 < $day9) { $zone = "-60"; } else { $zone = "0"; } break; case "C": if($day6 < $eg_Date1 && $eg_Date1 < $day1) { $zone = "-60"; } else { $zone = "0"; } break; case "D": if($day2 < $eg_Date1 && $eg_Date1 < $day4) { $zone = "-60"; } else { $zone = "0"; } break; case "DS": if($day5 < $eg_Date1 && $eg_Date1 < $day1) { $zone = "-60"; } else { $zone = "0"; } break; case "no": $zone = "0"; break; } $timediff = $zone + $timez; [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]Calculate the timedifference per country and insert it in below javascript as a (echo php) variable $timediff, this part goes into the body of your page.[!--colorc--][/span][!--/colorc--] [!--coloro:#33FF33--][span style=\"color:#33FF33\"][!--/coloro--]Note: the timedifference has to be in minutes[!--colorc--][/span][!--/colorc--] <!-- Adjust the placement of the clock in the line below --> <span id="timecontainer" style="position:absolute;left:90;top:15;"></span></font></font> <script type="text/javascript"> new showLocalTime("timecontainer", "server-php", <? echo $timediff ?>, "short") </script> [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]copy/paste below javascipt in the head of your page:[!--colorc--][/span][!--/colorc--] <script type="text/javascript"> var weekdaystxt=["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] function showLocalTime(container, servermode, offsetMinutes, displayversion){ if (!document.getElementById || !document.getElementById(container)) return this.container=document.getElementById(container) this.displayversion=displayversion var servertimestring=(servermode=="server-php")? '<? print date("F d, Y H:i:s", time())?>' : (servermode=="server-ssi")? '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' : '<%= Now() %>' this.localtime=this.serverdate=new Date(servertimestring) this.localtime.setTime(this.serverdate.getTime()+offsetMinutes*60*1000) //add user offset to server time 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 if (this.displayversion=="long") this.container.innerHTML=this.localtime.toLocaleString() else{ var hour=this.localtime.getHours() var minutes=this.localtime.getMinutes() var seconds=this.localtime.getSeconds() var ampm=(hour>=12)? "PM" : "AM" var dayofweek=weekdaystxt[this.localtime.getDay()] this.container.innerHTML=formatField(hour, 1)+":"+formatField(minutes)+":"+formatField(seconds)+" "+ampm+" ("+dayofweek+")" } setTimeout(function(){thisobj.updateContainer()}, 1000) //update container every second } function formatField(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 } </script> [a href=\"http://en.wikipedia.org/wiki/Daylight_saving_time#Europe\" target=\"_blank\"]http://en.wikipedia.org/wiki/Daylight_saving_time#Europe[/a] will give you more information on which country is in what zone.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.