JavaScript - What Timezone In This Script
I found a little script online, and it seems to work pretty good. But my question is, if someone lives in another time zone, will it display differently for them or will they see what I see? I'm not sure if this is grabbing the timezone from the server or from the users pc. Could anyone help?
Code: <script type="text/javascript"> var before="left until your track needs to be in." var current="Deadline is up." var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") function countdown(yr,m,d){ theyear=yr;themonth=m;theday=d var today=new Date() var todayy=today.getYear() if (todayy < 1000) todayy+=1900 var todaym=today.getMonth() var todayd=today.getDate() var todayh=today.getHours() var todaymin=today.getMinutes() var todaysec=today.getSeconds() var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec futurestring=montharray[m-1]+" "+d+", "+yr dd=Date.parse(futurestring)-Date.parse(todaystring) dday=Math.floor(dd/(60*60*1000*24)*1) dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1) dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1) dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1) if(dday==0&&dhour==0&&dmin==0&&dsec==1){ document.forms.count.count2.value=current return } else document.forms.count.count2.value=+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+before setTimeout("countdown(theyear,themonth,theday)",1000) } //enter the count down date using the format year/month/day countdown(2010,04,23) </script> Similar TutorialsI need to have a script which suggests a list of towns, their longitude/lattitudes and timezones based on the user filling in a field. I've seen scripts like this on many different web pages, so you type in "London" and then it suggests "London, England", "London Ontario" etc. and you can select the correct one. Is there a widely used method of generating a script like this? I'm thinking Google API might be used for this type of thing but I'm not sure. Hi all, Running Firefox 3.6.16 under Linux (64 bit Ubuntu 10.10), I found that the Javascript Date object incorrectly returns the time zone as "EST" (Eastern Standard Time) (I am in New York, USA, GMT-5/GMT-4). It is, however, returning the proper time OFFSET (i.e. GMT-4). Running Firefox 3.6.16 under Windows XP, the Date object correctly returns "EDT" (Eastern Daylight Time) as well as the correct GMT-4. Does Javascript in the browser get it's time info from the OS? Or more specifically, is this error a bug in FIREFOX, or in LINUX? Thanks...... -- Roger Ok Codies .... I am still new to javascript and trying to learn on my own to incress my productivity with my job so this is what I need .... I have to call customers back in a two hour window but that two hour window has to be entered on mountain time ... than I am in central time .. than what ever time zone my client is in. So what I am trying to do is ... I hit a drop down and select the Time zone ... than that pulls the two hour windows in the next drop down will give me the resulting 2 hour window for the Moutain time. I now its a simple convertion but when your dealing with 50 clients a day and trying not to over book each two hour slot ... well i start making mistakes. Any advice on a way I could build this ... I have tryed to nest an if statement to a drop down in html and it blew up on me. The webpage doesn't display the proper times when I load it up. The GMT variable deals with the Greenwich timezone, which that time is used with offset variables in order to get the right times from each respective time zone in the branch offices. So far it seems only houston and new york display the right times or close to it all the other ones are way off. Please help me find the right formulas thank you. <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!-- New Perspectives on JavaScript, 2nd Edition Tutorial 2 Case Problem 3 Jackson Electronics World Clock Author: Andy Duren Date: Filename: world.htm Supporting files: je.css, logo.mpg, map.jpg, zones.js --> <title>Jackson Electronics World Clock</title> <link href="je.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="zones.js"></script> <script type = "text/javascript"> function worldClock() { var today = new Date(); var offSet = today.getTimezoneOffset() * 60 * 1000; var GMT = addTime(today, offSet); var houstonoff = -360 * (60 * 1000); var time1 = addTime(GMT, houstonoff); //houston office time var washoff = -480 * (60 * 1000); var time2 = addTime(GMT, washoff); //washington office time var nyoff = -300 * (60 * 1000); var time3 = addTime(GMT, nyoff); //new york office time var englandoff = 0 * (60 * 1000); var time4 = addTime(GMT, englandoff); //london office time var japanoff = 540 * (60 * 1000); var time5 = addTime(GMT, japanoff); //tokyo office time var aussieoff = 660 * (60 * 1000); var time6 = addTime(GMT, aussieoff); //sydney office time document.zones.place1.value = showTime(time1); document.zones.place2.value = showTime(time2); document.zones.place3.value = showTime(time3); document.zones.place4.value = showTime(time4); document.zones.place5.value = showTime(time5); document.zones.place6.value = showTime(time6); } </script> </head> <body onload="setInterval('worldClock()', 1000)"> <form id="zones" name="zones" action=""> <div id="headbar"> <img src="logo.jpg" alt="Jackson Electronics" /> <h2>Corporate Headquarters World Clock</h2> </div> <div id="timemap"> <input id="place1" name="place1" size="7" /> <input id="place2" name="place2" size="7" /> <input id="place3" name="place3" size="7" /> <input id="place4" name="place4" size="7" /> <input id="place5" name="place5" size="7" /> <input id="place6" name="place6" size="7" /> <img src="map.jpg" alt="World Map" id="map" /> <table> <tr> <th id="name1">Houston</th> <th id="name2">London</th> <th id="name3">New York</th> <th id="name4">Seattle</th> <th id="name5">Sydney</th> <th id="name6">Tokyo</th> </tr> </table> <table> <tr> <td id="address3"> <p><b>Jackson Electronics USA</b><br /> 10010 Park Street<br /> New York, NY 10001<br /> <b>Phone: </b>(212) 555-1209<br /> <b>Fax: </b>(212) 555-4001 </p> </td> <td id="address4"> <p><b>Jackson Electronics Ltd.</b><br /> 2349 Mitchell Street<br /> Seattle, WA 65091<br /> <b>Phone: </b>(381) 555-5499<br /> <b>Fax: </b>(381) 555-3181 </p> </td> <td id="address1"> <p><b>Jackson Electronics Latin America</b><br /> 5150 Shasta Lane<br /> Houston, TX 32821<br /> <b>Phone: </b>(817) 555-8190<br /> <b>Fax: </b>(817) 555-2881 </p> </td> </tr> <tr> <td id="address2"> <p><b>Jackson Electronics Europe</b><br /> 18 Northland Avenue<br /> London, England WC2N 5EA<br /> <b>Phone: </b>(+44) 0 870 555 7081<br /> <b>Fax: </b>(+44) 0 870 555 1788 </p> </td> <td id="address5"> <p><b>Jackson Electronics Pacifica</b><br /> 171-105 Thomas Street<br /> Sydney NSW 2000, Australia<br /> <b>Phone: </b>(+61) 2 5555 8993<br /> <b>Fax: </b>(+61) 2 5555 7171 </p> </td> <td id="address6"> <p><b>Jackson Electronics Asia</b><br /> 1-2-99 Sumiyoshi<br /> Hakata-Ku<br /> Tokyo 140-8781 Japan<br /> <b>Phone: </b>(+81) 3 5551 7817<br /> <b>Fax: </b>(+81) 3 5551 2398 </p> </td> </tr> </table> </div> </form> </body> </html> Hi there, I'm new here in this forum and I've registered to ask a question about JavaScript or Jquery. I don't know which to use. I have my code php like that: <?php //Get the data from system and return in EU format function ShowDate() { $Date = date("d"."/"."m"."/"."Y"); return $Date; } //Get the time from system function ShowTime() { $Time = date("H".":"."i"); return $Time; } ?> Now I have two input box <html> <head> </head> <body> Type the date:<input name="txtdate" type="text" class="input" id="txtdate" title="e.g dd/mm/yyyy" value="<?php echo ShowDate(); ?>" size="9" maxlength="10"> <br> Type the time:<input name="txttime" type="text" id="txttime" value="<?php echo ShowTime(); ?>" size="5" maxlength="5"> <br> London: Friday May 21 2010 05:12:00 <br> New York: Friday May 21 2010 00:12:00<br> Hong Kong: Friday May 21 2010 12:12:00<br> Tokyo: Friday May 21 2010 13:12:00<br> </body> </html> So.... the important is the user can interactive with the date. If I change the date or time all this values will be change as well. Someone knows how can I do this? The field txtdate I will get from a calendar plugin (javascript) that I already put in my code. Thank you for your help. Andrei Andrade hiya guys im just trying to get some javascript working that will display on one html page multiple ticking digital clocks representing the accurate time of a host of differents countrys. i currently have managed to get a ticking clock on the page using +++++++++++++++++++++++++ var thetime=new Date(); var nhours=thetime.getHours(); var nmins=thetime.getMinutes(); var nsecn=thetime.getSeconds(); ++++++++++++++++++++++++++++++++ i now need to get other clocks on same page but with the live ticking time from other countrys. i tried for hours searching sites but could not find a solution i understood. i did however add simply add ++++++++++++++++++++ var nhours=thetime.getHours() +7; +++++++++++++++++++ the plus 7 i added was intended to add 7 hours to the clock then i could use this method for all the clocks and it did work it did change the time but there was a problem hong kong is about 8 hours ahead of the uk when its 8pm here its 2am there and if i use this method and i add 6 hours to the getHours variable it then makes the time 26hours rather than 3am here is my code i hope you can be of some help ++++++++++++++++++++++++++++++++++++++++++++++ <html> <HEAD> <TITLE>JavaScript Clock</TITLE> <SCRIPT language="JavaScript"> <!-- function ukclock() { var thetime=new Date(); //var mins=new Date(); //var secn=new Date(); var nhours=thetime.getHours(); //the line below same as above except the +num can be used to add hours to the clock //var nhours=thetime.getHours() +6; var nmins=thetime.getMinutes(); var nsecn=thetime.getSeconds(); var AorP=" "; if (nhours>=12) AorP="P.M."; else AorP="A.M."; if (nhours>=13) nhours-=12; if (nhours==0) nhours=12; if (nsecn<10) nsecn="0"+nsecn; if (nmins<10) nmins="0"+nmins; document.clockform.clockspot.value=nhours+": "+nmins+": "+nsecn+" "+AorP; setTimeout('ukclock()',1000); } //--> </SCRIPT> </head> <BODY onload="ukclock()"> <FORM name="clockform"> Current Time in UK: <INPUT TYPE="text" name="clockspot" size="15"> <br /> </FORM> </body> ++++++++++++++++++++++++++++++++++++++++++++++ I have a site where users enter there certain timezome (+1, +4, -8 etc) and i want to display a clock with the local time on their profile page so when people view there profile they can see currently what time it is for them. I currently a have this. Code: function timeclock() { var t=setTimeout("startclock()",500); } function startclock() { var x = new Date(); var hour = x.getHours(); var min = x.getMinutes(); var sec = x.getSeconds(); if (hour<10){hour="0"+hour} if (min<10){min="0"+min} if (sec<10){sec="0"+sec} document.getElementById("clock").innerHTML=hour+":"+min+":"+sec; timeclock(); } Is it possible to alter the date dependent on the timezone? Maybe put startclock(timezone) andchange it to new Date(timezone);? I have a twitter feed on my site and although am generally happy with it, the time-stamp for each tweet is several hours ahead of my time zone. I've looked through the js files to see if there is anything that allows me to set the timezone but cannot find anything. Anyone know how to reset the time to pacific standard time? Here's the URL http://www.kitchenprose.com/gmtest/index.html Can't for the life of me see anything in the code that controls time zone (would like Pacific Standard time, US) Code: $(document).ready(function() { $.Juitter.start({ searchType:"fromUser", // needed, you can use "searchWord", "fromUser", "toUser" searchObject:"gillesmarini", // needed, you can insert a username here or a word to be searched for, if you wish multiple search, separate the words by comma. // The values below will overwrite the ones on the Juitter default configuration. // They are optional here. // I'm changing here as a example only lang:"en", // restricts the search by the given language live:"live-125", // the number after "live-" indicates the time in seconds to wait before request the Twitter API for updates. placeHolder:"juitterContainer", // Set a place holder DIV which will receive the list of tweets example <div id="juitterContainer"></div> loadMSG: "Loading messages...", // Loading message, if you want to show an image, fill it with "image/gif" and go to the next variable to set which image you want to use on imgName: "loader.gif", // Loading image, to enable it, go to the loadMSG var above and change it to "image/gif" total: 4, // number of tweets to be show - max 100 readMo "Read it on Twitter", // read more message to be show after the tweet content nameUser:"text", // insert "image" to show avatar of "text" to show the name of the user that sent the tweet openExternalLinks:"newWindow", // here you can choose how to open link to external websites, "newWindow" or "sameWindow" filter:"sex->*BAD word*,porn->*BAD word*,****->*BAD word*,****->*BAD word*" // insert the words you want to hide from the tweets followed by what you want to show instead example: "sex->censured" or "porn->BLOCKED WORD" you can define as many as you want, if you don't want to replace the word, simply remove it, just add the words you want separated like this "porn,sex,****"... Be aware that the tweets will still be showed, only the bad words will be removed }); $("#aRodrigo").click(function(){ $(".jLinks").removeClass("on"); $(this).addClass("on"); $.Juitter.start({ searchType:"fromUser", searchObject:"mrjuitter,rodrigofante", live:"live-120" // it will be updated every 120 seconds/2 minutes }); }); $("#aIphone").click(function(){ $(".jLinks").removeClass("on"); $(this).addClass("on"); $.Juitter.start({ searchType:"searchWord", searchObject:"iPhone,apple,ipod", live:"live-20" // it will be update every 20 seconds }); }); $("#aJuitter").click(function(){ $(".jLinks").removeClass("on"); $(this).addClass("on"); $.Juitter.start({ searchType:"searchWord", searchObject:"Juitter", live:"live-180" // it will be updated every 180 seconds/3 minutes }); }); $("#juitterSearch").submit(function(){ $.Juitter.start({ searchType:"searchWord", searchObject:$(".juitterSearch").val(), live:"live-20", // it will be updated every 180 seconds/3 minutes filter:"sex->*BAD word*,porn->*BAD word*,****->*BAD word*,****->*BAD word*" }); return false; }); $(".juitterSearch").blur(function(){ if($(this).val()=="") $(this).val("Type a word and press enter"); }); $(".juitterSearch").click(function(){ if($(this).val()=="Type a word and press enter") $(this).val(""); }); }); Many thanks! Hi guys! Very new to registering here, but have lurked the forums for quite a while, and love the help I see the members give to those in need! Well, it's time to call myself: one of those in need! I'm building a "clan" website, and as such, there's things like clan events, competitions, and clan vs clan battles. However, the problem we have is that when listing the time, some people get confused with time zones, and as such, forget we Australians are a day ahead. As such, the easiest way to resolve this would be to have a date and time on the home page which we can then "refer" to when speaking about particular times an event is going to take place. What I pretty much want is something to say in text: "2:30am, Friday the 30th of October 2010" The GMT is going to be set to that of the server, so I'd like it to be GMT-7, so that when people visit the official game's server and see the time, they can then refer it back to our own time zone. I understand that a javascript script for date and time is available quite publically that can add or take 7 hours from your local time and call that the "GMT-7", but not everyone is on GMT+0, and as such, it gives multiple people different timings. I also want the time to update instantly (without refreshing the page). If I could PLEASE get some help, that would be greatly appreciated. I recently designed the website to be Halloween-related, and as such, want to launch it VERY soon (gosh, only 1 day to Halloween! HAPPY HALLOWEEN!), this is the only thing holding me back at the moment... Thank you for any help, I do very much appreciate it. (oh, p.s: I'm VERY new to javascript, and understand VERY little of it, if you give me a script and say "you can change the GMT to -7, please clearly indicate where I can do this as I won't be able to find it myself).. Thank you, thank you, thank you! Hi All, I have two scripts which I want to try and integrate. I am using a nice gallery script to show thumbnails which are appended to a an image wrapper which on click of the thumbnail shows the larger image in the image wrapper, I am trying to implement cloud zoom which is a plugin which uses image srcs to then point to an anchor href to show another larger zoom image either in the same place.. which is what I am trying to do or in another div beside. I have had to set me img srcs up in a certain way to easily enter some product details. and I need to try an manipulate the code to make it work to suit my file layout. I am using a var= images [ with a series of file locations and info such as below { src: 'romanticabride/thumbs/tn_Shauna.jpg', srcBig: 'romanticabride/images/Shauna.jpg', title: 'Shauna', longDescription: '<b><H1>Shauna</H1></b><br><b>Romantica Of Devon <br><br><h2>Sizes Available:</h2><br> 6 - 32.<b><br><b><br><b><b><b><H2>Colours Available:</h2><b><br>Various<br>Please Enquire Below<br><br><br><br><a href="mailto:tracy@cherishbridal.co.uk?subject=Web Enquiry Regarding Romantica Shauna Bridal Gown"class="enquiry rose glow" >Click To Enquire About This Item </a>' }, what I need is for cloud zoom to work when the main image wrapper is hovered over which means it will need to add a class or when the whichever srcBig: is hovered over it gets wrapped by href to make the script work . one of my pages is http://www.cherishbridal.co.uk/romaticabride.html the cloud zoom script is at http://www.professorcloud.com/mainsite/cloud-zoom.htm.. I am happy to share a jsfiddle with someone or explain further or post some code. Thank you in advance does any expert know how to pass parameters in the <script ..> tag? for instance; Code: <script type="text/javascript" src="script.js ?param1=val1¶m2=val2&etc "> in the javascript script.js, how would we read the params after the question mark? for example, google this; google shopping cart /v2_2/cart.js I have a script that works in seamonkey(my html editor) but when I use it in IE8 it says errors happen. Here's the code (the first line is on line 7 of the html file): Code: <script type="text/javascript"> function enlarge(imageNum) { var numToString = ""; if(parseInt(imageNum) < 10){ numToString = "0" + imageNum; } else { numToString = imageNum + ""; } window.open("images/LgScreenshot"+numToString+".jpg","Screenshot "+imageNum,"status=0,height=675,width=900,resizable=0"); } </script> And the errors: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB0.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; InfoPath.3; .NET CLR 3.0.30729) Timestamp: Wed, 10 Feb 2010 14:58:16 UTC Message: Object expected Line: 150 Char: 1 Code: 0 URI: http://samssc2site.co.cc/Features.html Message: Invalid argument. Line: 18 Char: 1 Code: 0 URI: http://samssc2site.co.cc/Features.html I need to assign a key in the javascript to actually make the javascript work,. I have a bookmark in chrome , a javascript , which actually works when clicked on it .,. but how can i edit it so that i can actually make it work on click a key or combination of keys. i want to declare the key or keycombo in the script itself .,. the script is for catching the selected text on the webpage and opening a new tab(or window) and doing an exact search search of the selected text using google.com .,., So I want it to work it this way ., select the text press a key and it opens a new tab (or window) with an xact search .,. i want to declare the key or keycombo in the script itself .,. the script is for catching the selected text on the webpage and opening a new tab(or window) and doing an exact search search of the selected text using google.com .,., So I want it to work it this way ., select the text press a key and it opens a new tab (or window) with an xact search .,. Thanks in advance ., Nani On this website: http://evancoleman.net/index.php I really like on the top how the menu has like 5 or 6 icons, and when you hover over them it shows a bubble with the name in them. Does anybody know where I can find this script? Thanks. Hello again . If these questions concerning Regular Expressions are inappropriate in this forum please let me know . Thank You. This expression <script[^>]*>.*?</script> matches ... Code: <script type="text/javascript">var cnnIsHomePage = true;</script> but not ... Code: <script type="text/javascript"> var cnnIsHomePage = true; </script> Please , how can i match the latter ? Hey, I have a forum, and the forum has an rss feed. I want to take the most 10 recent posts from the feed and insert it into my Home page. I have no clue how to do this. At the moment I have been manually entering the posts as you can see here. All the recent posts on the right side of the page are manually entered by me from my forum. Just wondering if anyone could guide me in a direction to do this programmatically. I have new script and i need to fix it for : 1-This script opens windows behind current windows when visitor clicks everywhere on the page . I need it works when visitors click only on links not everywhere on the page 2-i need it works for links with speacial id's , not every links <script type="text/javascript"> var puShown = false; function doOpen(url) { if ( puShown == true ) { return true; } win = window.open(url, 'ljPu', 'toolbar,status,resizable,scrollbars,menubar,location,height=680,width=790'); // win = window.open(url, 'ljPu', 'height=680,width=790'); if ( win ) { win.blur(); puShown = true; } return win; } function setCookie(name, value, time) { var expires = new Date(); expires.setTime( expires.getTime() + time ); document.cookie = name + '=' + value + '; expires=' + expires.toGMTString(); } function getCookie(name) { var cookies = document.cookie.toString().split('; '); var cookie, c_name, c_value; for (var n=0; n<cookies.length; n++) { cookie = cookies[n].split('='); c_name = cookie[0]; c_value = cookie[1]; if ( c_name == name ) { return c_value; } } return null; } function initPu() { if ( document.attachEvent ) { document.attachEvent( 'onclick', checkTarget ); } else if ( document.addEventListener ) { document.addEventListener( 'click', checkTarget, false ); } } function checkTarget(e) { if ( !getCookie('popundr') ) { var e = e || window.event; var win = doOpen('go.php?link=trade2'); setCookie('popundr', 1, 1*60*60*1000); } } initPu(); </script> Hello this small clickunder script open windows behind current windows but it has problems that i want to be fixed : 1-This opens windows behind current windows when visitor clicks everywhere on the page . I need it works when visitors click only on links not everywhere on the page 2-i need it works for links with speacial id's , not every links Code: <SCRIPT LANGUAGE="Javascript"> function PopShow3() { CookieTest=navigator.cookieEnabled; if(CookieTest) { ClickUndercookie = GetCookie('clickunder'); if (ClickUndercookie == null) { var ExpDate = new Date (); ExpDate.setTime(ExpDate.getTime() + (1 * 60 * 60 * 1000)); SetCookie('clickunder','1',ExpDate, "/"); window.open("galst2.htm"); window.focus(); } } } function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function SetCookie (name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } document.onmouseup=PopShow3; </SCRIPT> someone please delete this!!
I'm looking for something that i can put into my HTML page that will display the following information about the users computer: OS version, browser version, quicktime + flash + adobe reader + java + windows media player + sliverlight versions of the users computer. Can anyone please help??? I don't know a lot about this so something i could copy and paste would be great! I need it to work across all the major browser types. Thanks!!!! |