Ok, this problem is actually much simpler than I realized at first. All that you need to do is use the original version of this Local Time script that we've been talking about. Adding just one variable and perhaps doing a little trial and error math will get you what you are looking for. Add this variable (highlighted red) near the top of the script:
And use this method to call the script from the body:Code:/*********************************************** * 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. ***********************************************/ var weekdaystxt=["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"] var localOffset=new Date().getTimezoneOffset()*-1
Now, in many cases your server time is already GMT or may be fetched that way by this script. If so, the local time displayed will be correct and you are done. If it is not, that is where a little trial and error comes in. Determine the hours difference between the time displayed and your true local time, multiply by 60 and either add or subtract it in the call. For example, let's say that the time displayed is 3 hours later than it should be. 3 times 60 is 180, so you need to subtract it from the local offset:Code:Current Local Time: <span id="timecontainer"></span> <script type="text/javascript"> new showLocalTime("timecontainer", "server-php", localOffset, "long") </script>
That's it! Once you have the adjustment worked out for your locality it will be correct in any time zone. If you need help formatting the output (like before) once you have this working, let me know.Code:new showLocalTime("timecontainer", "server-php", [localOffset-180], "long")



Reply With Quote



Bookmarks