JavaScript - Time Of Day/week/hour Message Help
Hi i have been looking everywhere and cant seem time to find anything matching,
what i need is a scheduled message on a website, basically stating days of the week and time and who is live on air. also people maybe on air at 17.30 so i have no idea on how to code this. e.g Monday 15th August 17:45 - On Air Now, Lee Mills so it also refreshes every 1 minute Thank you for your help. Similar TutorialsHi, I have a webpage with a world clock. On the clock page are 12 buttons (World Cities). When the user clicks these buttons. The time for the relevant world city is displayed. (The time is updated by an on.click function for each individual button. That either subtracts or adds the hours from GMT. For example. If the time is GMT 18:00:00. The user clicks the Paris button and the function adds 1 hour to result in 19:00:00) However. If the GMT time is for example 21:00:00 and the user clicks the Tokyo button (GMT+9 hours). The time displayed is 30:00:00. So I have been trying to work out how I can stop the time adding past 23:59:59. This is probably so simple which is probably why I cant find any help online. It has stumped me and any help would be appreciated. I have copied and pasted my code below in the hope that helps. Thanks in advance if you can offer any advice. Code: <script> function start() { GMToffset = 0; t=setInterval('digitalclock()',500); } function digitalclock() { var today=new Date(); var hours=today.getHours() + GMToffset; var minutes=today.getMinutes(); var seconds=today.getSeconds(); minutes=checkTime(minutes); seconds=checkTime(seconds); hours=checkTime(hours); document.getElementById('txt').innerHTML=hours+":"+minutes+":"+seconds; } function checkTime(i) { if (i<10) { i="0" + i; } return i; } function updatetime1() { GMToffset = -3; } function updatetime2() { GMToffset = -4; } function updatetime3() { GMToffset = -7; } function updatetime4() { GMToffset = -10; } function updatetime5() { GMToffset = -11; } function updatetime6() { GMToffset = -13; } function updatetime7() { GMToffset = +9; } function updatetime8() { GMToffset = +8; } function updatetime9() { GMToffset = +7; } function updatetime10() { GMToffset = +1; } function updatetime11() { GMToffset = +0; } function updatetime12() { GMToffset = +3; } </script> <div align="center"> <input type="button" onclick="updatetime1()" value="Time in Buenos Aires" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime2()" value="Time in New York" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime3()" value="Time in San Francisco" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /><br> <input type="button" onclick="updatetime4()" value="Time in Hawaii" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime5()" value="Time in Fiji" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime6()" value="Time in Sydney" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /><br><br> <body onload="start()"> <div id="txt"></div> </div> <div align="center"> <input type="button" onclick="updatetime7()" value="Time in Tokyo" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime8()" value="Time in Hong Kong" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime9()" value="Time in Bangkok" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /><br> <input type="button" onclick="updatetime10()" value="Time in Rome" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime11()" value="Time in London" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime12()" value="Time in Moscow" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> Hello, I was wanting a message to be displayed if it is the visitors first time to the site. It will be a toolbar displayed at the top of the website, with links to FAQ's. Any method of display this is fine. Thanks Hi, I have the following code which *should* change the image I have on my webpage to images based on the time. Code: function timeDate() { var t=new Date(); var h = d.getHours(); var r1="images/datetime/1.png"; var r2="images/datetime/2.png"; var r3="images/datetime/3.png"; var r4="images/datetime/4.png"; var r5="images/datetime/5.png"; var r6="images/datetime/6.png"; var r7="images/datetime/7.png"; var r8="images/datetime/8.png"; var r9="images/datetime/9.png"; var r10="images/datetime/10.png"; var r11="images/datetime/11.png"; var r12="images/datetime/12.png"; var r13="images/datetime/13.png"; var r14="images/datetime/14.png"; var r15="images/datetime/15.png"; var r16="images/datetime/16.png"; var r17="images/datetime/17.png"; var r18="images/datetime/18.png"; var r19="images/datetime/19.png"; var r20="images/datetime/20.png"; var r21="images/datetime/21.png"; var r22="images/datetime/22.png"; var r23="images/datetime/23.png"; var r24="images/datetime/00.png"; var el=document.getElementById('hours'); el.src = (h == 1) r1; el.src = (h == 2) r2; el.src = (h == 3) r3; el.src = (h == 4) r4; el.src = (h == 5) r5; el.src = (h == 6) r6; el.src = (h == 7) r7; el.src = (h == 8) r8; el.src = (h == 9) r9; el.src = (h == 10) r10; el.src = (h == 11) r11; el.src = (h == 12) r12; el.src = (h == 13) r13; el.src = (h == 14) r14; el.src = (h == 15) r15; el.src = (h == 16) r16; el.src = (h == 17) r17; el.src = (h == 18) r18; el.src = (h == 19) r19; el.src = (h == 20) r20; el.src = (h == 21) r21; el.src = (h == 22) r22; el.src = (h == 23) r23; el.src = (h == 24) r24; } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(function() { timeDate(); }); I am a very new to JavaScript, and I don't know why this won't work. It should compare the hour variable (h) to the hour, and then change the image based on that. However it doesn't do this, and I'm not sure why. I've tried using both = and ==, but neither seem to work. Like I said I am a newbie to this sort of stuff. Can anyone point me in the right direction to fixing this? Also, would there be a way of making the el.src to: "images/timedate/"+[the hour]+".png" without the need of directly comparing the hours? It would be useful if it was possible, as I need to do a minutes one as well Thank you very much in advance I have calendars on my site where tenants can make reservations for shared rooms. The start times are listed in a drop down starting at 8am and going through 5pm at one hour intervals. What I'd like to be able to do is make the drop down be populated 1 hour from the current time. For example, if it is 8 now, I'd like the time in the drop down to start at 9. Is this something that's possible or wishful thinking?
Hi,my current pop under code works ever 24hrs,but I would like to change it to work every hour,and/or to work every time a member clears his cookies.If I am not explaining this correctly please let me know and I will try to correct this. Code: function setCookie(name, value, time) { var expires = new Date(); expires.setTime( expires.getTime() + time ); document.cookie = name + '=' + value + '; expires=' + expires.toGMTString(); } Any help with this would be greatly appreciated!! Mike Edit:If you need me to post the whole code I have no prob with this.I only posted this part because I thought the issue would be in var expires = new Date();. Just want to know what should I change it to? Here is the whole code. Code: <script type="text/javascript"> var puShown = false; function doOpen(url) { if ( puShown == true ) { return true; } win = window.open(url, 'wmPu', 'toolbar,status,resizable,scrollbars,menubar,location,height=700,width=1100'); 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('My Site Name Here/'); setCookie('popundr', 1, 24*60*60*1000); } } initPu(); </script> I do know that most of you hate pop ups and pop unders,but this is not to annoy my users.I am just using this to promote another site that I own..Thanks again. I need help with a counter that will either display a different image everyweek or change text every week. The scenario is a counter will be on the top right corner of the page, and every week the number will change from 1 to 2 to 3... to 52... I searched on this forum for answers, i found some similar for a different day counter. Any help would be great! I want to be able to pass in any given date and return the week of month that it lies within. Weeks will start on Monday. Also if Day 1 and 2 are saturday and Sunday, those should be labeled as week 1. Any Ideas?
Hi there, me again. Need help with this bit of code. The script itself I got from the JS Source, and modified it myself a bit so that instead of the user inputting their DOB via a prompt box, it could be entered via dropdown lists. I attempted to do this, but have come across a problem. For some reason, the result always (or at least, that's what it looks like to me) appears to be the array index element of [4], i.e. Friday. Not really sure why this is, but no matter what date is entered out of the example dates shown below in the HTML, the result is always Friday. Double-checked on another similiar calculator script online, and sure enough, the results are wrong. So it's a problem with my script. Except I can't identify it. So any help from Old Pedant/Philip M, or whoever else on the forum has the patience to help me , would be much appreciated. Code: <script type="text/javascript" language="javascript"> function findDay() { var arr = new Array(); arr[0] = "Monday"; arr[1] = "Tuesday"; arr[2] = "Wednesday"; arr[3] = "Thursday"; arr[4] = "Friday"; arr[5] = "Saturday"; arr[6] = "Sunday"; var selectdate = document.getElementById("selectdate").selectedIndex; var selectmonth = document.getElementById("selectmonth").selectedIndex; var selectyear = document.getElementById("selectyear").selectedIndex; var birthday = new Date(selectdate + selectmonth + selectyear); var day = birthday.getDay(); document.getElementById("div1").innerHTML = "You were born on a " + arr[day] + "!" } </script> Code: <html> <h1>Day Of The Week?</h1> Input your date of birth, and click the Go button to find out what day of the week you were born on. <hr/> <form style="text-align: center;"> <select id="selectdate"> <option>1</option> <option>2</option> <option>3</option> </select> <select id="selectmonth"> <option>January</option> <option>February</option> <option>March</option> </select> <select id="selectyear"> <option>1995</option> <option>1996</option> <option>1997</option> </select> <br/> <br /> <input align="middle" type="button" value="Go" onclick="findDay()"> </form> <div id="div1"></div> </html> I have been using a javascript code to display a "Please wait..." message on screen but it seems to work in some instances and not in others. Please assist me with javascript code that works in all instances Issue 1:- it doesnt pops up with d wait msg ven v click on buttons.. the buttons are not submit buttons.. instead on clicking dat button it calls a fnformsubmit() userdfnd funtion.. Issue 2:-- even after d response cums the wait msg window doesnt close.. it hangs in d backgrnd.. The foll code is used in the footer.jsp file... Please assist... <html> <head> <script type="text/javascript" src="/js/os/jquery-1.5.1.min.js" ></script> <script type="text/javascript" src="/js/os/jquery-ui-1.8.14.custom.min.js"></script> <link rel="stylesheet" type="text/css" media="all" href="/js/os/jquery-ui-1.8.14.custom.css"> <script type="text/javascript"> for (var i = 0; i < document.links.length; i++) { var attrib = document.links[i]; if (attrib.addEventListener) { attrib.addEventListener('click', attachModalDialog, false); } else if (attrib.attachEvent) { attrib.attachEvent('onclick', attachModalDialog); } } function attachModalDialog(evt) { //alert('for Click event.'); $(ModalDialog).dialog({ modal: 'true', title: 'Please Wait...', width: 400, height: 300, closeOnEscape: false }).dialog('open'); return true; } </script> </head> <body> <div id="ModalDialog" style="display:none;"> <pre> Server side process is in-progress. Please wait..... </pre> </div> </body> </html> Hi everyone, I have a countdown script I'd like to modify so that the countdown ends at a specific hour, and not on a particular day at midnight. I'm new to coding (Ruby), so still trying to get the hang of Javascript: Code: var current="Expired" 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.getElementById('counter').style.display='none'; document.getElementById('expired').style.display='block'; return } else{ document.getElementById('countdown_day').innerHTML=dday; document.getElementById('countdown_hour').innerHTML=dhour; document.getElementById('countdown_min').innerHTML=dmin; document.getElementById('countdown_sec').innerHTML=dsec; setTimeout("countdown(theyear,themonth,theday)",1000) } } //MODIFY THIS LINE: enter the count down date using the format year/month/day //e.g. countdown(2009, 03, 23); countdown(2011, 12, 24); I've tried to play with it by changing the following in green: Code: function countdown(yr,m,d, h ){ theyear=yr;themonth=m;theday=d; thehour=h . . . setTimeout("countdown(theyear,themonth,theday, thehour )",1000) . . countdown(2011, 12, 24, 10 ) But I don't seem to be getting anywhere. Any tips or pointers to push me in the right direction is much appreciated. Thanks! Hello! I do my calendar (vertical) =) and I've done to date were down But how to do that day of the week displayed on the side of the date of Here is code: Code: <html><head><title>Calendar</title> <meta http-equiv="content-type" content="text/html; charset=windows-1251" /> </head> <body><center> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin monthnames = new Array("January","Febrary","March","April","May","June","July","August","September","October","November","December"); var linkcount=0; function addlink(month, day, href) { var entry = new Array(3); entry[0] = month; entry[1] = day; entry[2] = href; this[linkcount++] = entry; } Array.prototype.addlink = addlink; linkdays = new Array(); monthdays = new Array(12); monthdays[0]=31; monthdays[1]=28; monthdays[2]=31; monthdays[3]=30; monthdays[4]=31; monthdays[5]=30; monthdays[6]=31; monthdays[7]=31; monthdays[8]=30; monthdays[9]=31; monthdays[10]=30; monthdays[11]=31; todayDate=new Date(); thisday=todayDate.getDay(); thismonth=todayDate.getMonth(); thisdate=todayDate.getDate(); thisyear=todayDate.getYear(); thisyear = thisyear % 100; thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear)); if (((thisyear % 4 == 0) && !(thisyear % 100 == 0)) ||(thisyear % 400 == 0)) monthdays[1]++; startspaces=thisdate; while (startspaces > 7) startspaces-=7; startspaces = thisday - startspaces + 1; if (startspaces < 0) startspaces+=7; document.write for (s=0;s<startspaces;s++) { document.write(); } count=1; while (count <= monthdays[thismonth]) { for (b = startspaces;b<7;b++) { linktrue=false; /////displays the date document.write("<br width='30'>"); if (count <= 31) { document.write(monthnames[thismonth]); document.write(" "); } for (c=0;c<linkdays.length;c++) { if (linkdays[c] != null) { if ((linkdays[c][0]==thismonth + 1) && (linkdays[c][1]==count)) { document.write("<a href=\"" + linkdays[c][2] + "\">"); linktrue=true; } } } if (count==thisdate) { document.write("<font color='FF0000'><strong>"); } if (count <= monthdays[thismonth]) { document.write(count); } else { document.write(" "); } if (count==thisdate) { document.write("</strong></font>"); } if (linktrue) document.write("</a>"); document.write; count++; } document.write; document.write("<tr>"); startspaces=0; } document.write("</p>"); // End --> </SCRIPT> </center></body> </html> Can anyone link me to code that will change an image everyweek to an image that I define? I have 52 different images, one for every week.
From:tibettravel.org According to source from Lhasa's transportation management office, local vehicles in public transportation, farming and forestry sectors will enjoy a direct financial subsidy from the municipal government of Lhasa, capital city of southwest China's Tibet Autonomous Region. Urban cabs will get 110 yuan and urban buses will get 100 yuan per month for each while buses of rural routes will ge 120 yuan per month for each. Transportation service companies should collect the monthly operation information of all vehicles and then report to the municipal transportation management office. Subsidies will be delivered directly to the companies and then transferred to vehicle owners or drivers after financial verification. Sources from: China Tibet Online;Reported by:tibettravel.org Hi, Please i am not getting clear understanding of a javascript code to redirect user to a different web page based on the day of the week. Please i have search for many script and not getting clear understanding from their code.I have also try several code myself but nothing good has come from it. Please can someone help me and write a descriptive code for me to understand better.I really plead you and your to help me...but i belief the Lord God will bless you for your time helping me. looking forward to here from you. Thank you. Clement Osei Hi Code: var err_str=""; function validate_grid(value,id,ind) { $("#result").html(" ").show(); if(ind==1 || ind==2) { var patt=/^([0][0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/; if(!patt.test(value)) { mygrid.setCellTextStyle(id,ind,"background-color:yellow;"); if(err_str!="") err_str+="\n"+(ind+1)+".Enter numbers and : only.."; else err_str=(ind+1)+".Enter numbers and : only"; return false; } else { mygrid.setCellTextStyle(id,ind,"background-color:white;"); return true; } } } alert(err-str); here ind==1 is from_time and ind==2 is to_time,i need to validate time as to_time must be always greater than from-time,if condition fails an alert msg should populate.time format is[05:00]as it is in string format im unable to do the validation for it.(ex:from-time=08:00 to-time=07:59 condition fails) thank you. hi im using dhtml xgrid where i need to do validation for time ,(from-time and to-time i.e ind==1 and ind==2 ) to-time must be greater than from-time else i need to alert a message to-time must be greater than from-time. can any one send me the code for it time format is[05:00]. Code: var err_str=""; function validate_grid(value,id,ind) { $("#result").html(" ").show(); if(ind==1 || ind==2) { var patt=/^([0][0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/; if(!patt.test(value)) { mygrid.setCellTextStyle(id,ind,"background-color:yellow;"); if(err_str!="") err_str+="\n"+(ind+1)+".Enter numbers and : only.."; else err_str=(ind+1)+".Enter numbers and : only"; return false; } else { mygrid.setCellTextStyle(id,ind,"background-color:white;"); return true; } } } Hello im using dhtmlx grid in this cells i have from time and to time (i.e ind==1 and ind==2) i need to validate time where to-time must be greater than from-time else it should alert an message,i have writeen a normal Regular expression for the time validation.as the time is i string format i.e[05:00],please can any one send me code for that. Code: var err_str=""; function validate_grid(value,id,ind) { if(ind==1 || ind==2) { var patt=/^([0][0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/; if(!patt.test(value)) { mygrid.setCellTextStyle(id,ind,"background-color:yellow;"); if(err_str!="") err_str+="\n"+(ind+1)+".Enter numbers and : only.."; else err_str=(ind+1)+".Enter numbers and : only"; return false; } else { mygrid.setCellTextStyle(id,ind,"background-color:white;"); return true; } } } 1 down vote favorite I do have the countdown script (see link below) to display the time between current time and the date given in real-time. However, I want to achieve to display the time difference between a given start and end time. Right now, it calculates from the current server time to the end time. I want to be able to set up my own start time and end time. Here is what I have: http://jsfiddle.net/BgEtE/ thank you for help hi, can some one help me how to get the time and date difference? given two time and date with the following format like in textbox A: 2011-05-03 17:35:47.0 and textbox B: 2011-05-03 16:35:47.0 then the output would be: 0 days, 1 hour, 0 minutes, 0 seconds regards, verve |