JavaScript - Multi-timezone-clock
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> ++++++++++++++++++++++++++++++++++++++++++++++ Similar TutorialsHi 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 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> 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 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> 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. 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);? 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! 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! I 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. Hello. I am trying to stop and then start my clock, but something goes wrong Code: <script type="text/javascript"> function start_clock(){ var today = new Date(); var h = today.getHours(); var m = today.getMinutes(); var s = today.getSeconds(); // add a zero in front of numbers<10 m = checkTime(m); s = checkTime(s); document.getElementById('clck').innerHTML = h+":"+m+":"+s; t=setTimeout('start_clock()'); } function checkTime(i) { if (i<10) { i="0" + i; } return i; } var intval="" function start_Int(){ if(intval==""){ intval=window.setInterval("start_clock()",1000) }else{ stop_Int() } } function stop_Int(){ if(intval!=""){ window.clearInterval(intval) intval="" myTimer.innerHTML="Interval Stopped" } } </script> <h1>A live clock in JavaScript</h1> </head> <body onload="start_clock()"> <p>The time according to your PC is </p> <span id="clck">Interval Stopped</span> <br><br><br> <input type="button" value="Start" onclick="start_Int()"> <input type="button" value="Stop" onclick="stop_Int()"> Any help will be appreciated. Hello, I'm somewhat new to JavaScript and for my website, I decided to make a clock for the website in this format: Saturday, October 17, 2009 5:56:14 p.m. The only issue is that it won't update every second. Below is the coding: External JavaScript: Code: function dateClock() { // Coding } setTimeout("dateClock()", 1000); HTML: Code: ... <script src="date.js" type="text/javascript"> </script> </head> <body> <script type="text/javascript"> document.write("<p style='margin:-15px 0px;background-color:black;position:fixed;padding:5px;'>"+Day+", "+Month+" "+date+", "+Year+"<br />"+Hour+":"+Minute+":"+Sec+" "+Suffix+"</p>"); </script> What can I do to make it update? Thanks. Hello, I would like help about my problem. I want to find the proper function to manage a clock . What I want to do is, when a city is selected from the drop down menu, the display of the clock must be changed depended by the city . Also to allow the user to vary the values of the three variables that control the display of a clock. <body onload="globalclock()"> <input type="text" size="50" id="globalclock" /> <select ......... onchange=""> <option value=''>select city</option> <option value='0'>Athens</option> <option value='1'>New York</option> .... .... <option value='36'>.........</option> </select> //default clock dow="f"; cdate="a"; ctime="a"; city = "22"; //its my default city when page load I use globalclock() function but with no results I figured if there was one it would be a Javascript but does anyone know of a countdown clock that almost looks like a counter/turnstile number row? Like this sorta: I've been looking for one where I have the numbers look just like that and 'push' upward as the times (days, minutes, seconds) go on. Hopefully someone knows of a script >< Thanks alot!!! Hey all, I'm trying to sort a countdown clock for my website: http://www.cyber-technix.com/corps/index.php/ My vision of it was a transparent background, Blue text and a simple Day : Hour : Minute : Second Layout. I found a free .js countdown clock at http://www.hashemian.com/tools/javascript-countdown.htm Anyone got any better suggestions? I havn't used .js much so I may need some help implementing it if someone would be kind enough to help me out, thanks. Hello to everyone . i have a clock from a javascript code and i want through drop down list to change the time location (city) the html part Code: <body onload="globalclock()"> <input type="text" size="50" id="globalclock" /> <select ......... onchange=""> <option value=''>select city</option> <option value='0'>Athens</option> <option value='1'>New York</option> .... .... <option value='36'>.........</option> </select> the only way to display the clock is to set values Code: //default clock dow="f"; cdate="a"; ctime="a"; city = 5; //its my default city when page load can anyone help me to manage this :-) Thankz Javascript for clock: Code: function showTime (dateObj) { thissecond=dateObj.getSeconds(); thisMinute=dateObj.getMinutes(); thisHour=dateObj.getHours(); // change thisHour from 24-hour time to 12-hour time by: // 1) if thisHour < 12 then set ampm to "a.m." otherwise set it to "p.m." var ampm = (thisHour < 12) ? "a.m." : "p.m."; // 2) subtract 12 from the thisHour variable thisHour = (thisHour > 12) ? thisHour - 12 : thisHour; // 3) if thisHour equals 0, change it to 12 thisHour = (thisHour == 0) ? 12 : thisHour; // add leading zeros to minutes and seconds less than 10 thisMinute = thisMinute < 10 ? "0"+thisMinute : thisMinute; thisSecond = thisSecond < 10 ? "0"+thisSecond : thisSecond; return thisHour + ":" + thisMinute + ":" + thisSecond + ampm; } HTML for page: Code: <?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"> <!-- New Perspectives on JavaScript, 2nd Edition Tutorial 3 Tutorial Case The Chamberlain Civic Center Author: Date: Filename: ccc.htm Supporting files: back.jpg, calendar.css, calendar.js, ccc.css, ccc.jpg, logo.gif --> <title>The Chamberlain Civic Center</title> <link href="ccc.css" rel="stylesheet" type="text/css" /> <link href="calendar.css" rel="stylesheet" type="text/css" /> <script src="calendar.js" type="text/javascript"></script> </head> <body> <div id="head"> <script type="text/javascript"> calendar("March 25, 2011"); </script> <img src="ccc.jpg" alt="Chamberlain Civic Center" /> </div> <div id="links"> <table><tr> <td><a href="#">Home</a></td><td><a href="#">Tickets</a></td> <td><a href="#">Events</a></td><td><a href="#">Tour</a></td> <td><a href="#">Directions</a></td><td><a href="#">Hours</a></td> <td><a href="#">Packages</a></td><td><a href="#">Contact Us</a></td> </tr></table> </div> <div id="main"> <p id="firstp"><img src="photo.jpg" alt="" />March is another banner month at the Chamberlain Civic Center, with performances of the award-winning musical, <span>The Producers</span> by the Broadway Touring Company on March 4, 5, and 6. Tickets are going fast, so order yours today.</p> <p>Celebrate the season on March 11 with the Chamberlain Symphony and their special selection of classical music with Spring themes. The next day, March 12, exercise your mind by attending the Charles Dickens mystery <span>Edwin Drood</span>.</p> <p>Jazz lovers have a lot to celebrate in March with a visit from <span>The Jazz Masters</span> on the 17th. Then on March 24, enjoy the music of The Duke with <span>An Ellington Tribute</span> performed by the Jazz Company of Kansas City.</p> <p>Pins, bottles, plates, and chairs are flying at the Chamberlain Civic Center in March. <span>The Taiwan Acrobats</span> return with another amazing performance on Sunday, March 13. On March 20, the <span>Madtown Jugglers</span> get into the act with their unique blend of comedy, juggling, and madness.</p> <p>Enjoy a classical brunch every Sunday afternoon with music provided by the Carson Quartet. Seating is limited, so please reserve your table.</p> </div> <address> The Chamberlain Civic Center · 2011 Canyon Drive · Chamberlain, SD 57325 · (800) 555-8741 </address> </body> </html> CSS for page: Code: /* New Perspectives on JavaScript, 2nd Edition Tutorial 3 Tutorial Case Filename: ccc.css This file contains styles used in the ccc.htm file */ body {margin: 0px; background: white url(back.jpg) repeat-y scroll 820px 0px} #head {width: 750px; height: 150px; padding: 5px} #links {clear: right; width: 750px; padding: 0px} #links table {width: 750px; font-family: Arial, Helvetica, sans-serif; font-size: 8pt; margin: 0px} #links table td {text-align: center; background-color: white; border: 1px solid black; letter-spacing: 5; padding: 2px} #links table a {text-decoration: none; color: rgb(223,29,29); width: 100%} #links table a:hover {color: white; background-color: rgb(223,29,29)} #main {width: 750px; font-family: Arial, Helvetica, sans-serif; padding: 10px} #main p {text-align: justify; font-size: 9pt} #firstp:first-line {font-variant: small-caps} #main img {float: right; margin: 0px 0px 10px 10px} #main p span {color: rgb(223,29,29)} address {width: 750px; font-size: 8pt; font-style: normal; color: rgb(223,29,29); font-family: Arial, Helvetica, sans-serif; text-align: center; border-top: 1px solid rgb(223,29,29); padding-bottom: 10px} Does anyone know how to put my clock into my HTM and CSS files to have it appear at the top left of the page? Please, help. Thanks. Hello, I am trying to create a clock for my video game. I need to begin the clock at zero and count while the game is going. I need to have the clock count in standard minutes and seconds but not be based on the actual time of day. I am coding in javascript for an applet.
Hello all! For the past few days I've been having trouble trying to figure out how to do something. I want to code a world population clock similar to the one here, but simpler: I want the user to be able to choose future years up to 2020 (just years, not months/days), and have the population grow by 1 percent each year. So far I have a code for the world population, but I have no clue where to begin in terms of making a list of the years with the option to increase the population. Could anyone point me in the right direction? I'd appreciate any help! Heres the code I have: <body> <script type="text/javascript"> function maind(){ startdate = new Date() now(startdate.getYear(),startdate.getMonth(),startdate.getDate(),startdate.getHours(),startdate.getM inutes(),startdate.getSeconds()) } function ChangeValue(number,pv){ numberstring ="" var j=0 var i=0 while (number > 1) { numberstring = (Math.round(number-0.5) % 10) + numberstring number= number / 10 j++ if (number > 1 && j==3) { numberstring = "," + numberstring j=0} i++ } numberstring=numberstring if (pv==1) {document.getElementById("worldpop").innerHTML=numberstring } } function now(year,month,date,hours,minutes,seconds){ startdatum = new Date(year,month,date,hours,minutes,seconds) var now = 5600000000.0 var now2 = 5690000000.0 var groeipercentage = (now2 - now) / now *100 var groeiperseconde = (now * (groeipercentage/100))/365.0/24.0/60.0/60.0 nu = new Date () schuldstartdatum = new Date (96,1,1) secondenoppagina = (nu.getTime() - startdatum.getTime())/1000 totaleschuld= (nu.getTime() - schuldstartdatum.getTime())/1000*groeiperseconde + now ChangeValue(totaleschuld,1); timerID = setTimeout("now(startdatum.getYear(),startdatum.getMonth(),startdatum.getDate(),startdatum.getHours( ),startdatum.getMinutes(),startdatum.getSeconds())",200) } window.onload=maind </script> Current world population (estimated): <span id="worldpop" style="font-weight: bold"></span>. </body> Hello Guys, Any one help me coding of java script coding for watch implementation in our website..... Thanks in Advance Hi, JS newbie here. Could someone please let me know how I would output the day as well in this world clock example? Thanks in advance. |