This is a bit of a spill over from the "HTML" thread. I took a look at that site and figured out how to make some of the modifications to that code that I want but not all.
I have attached the file as I have it now. I want to change the time zone so it is -1 hour to what it is and I want to right-align the text.
How would I go about doing those things?
david eaton
05-07-2003, 02:28 PM
Jes.
To change the time zone, the easiest method is to change the references to pacific standard time to another time zone.
As for the right align text, AFAIR, you could make the document Write statement like this
DocumentWrite<p align="right">(time)
Hope that helps! That'a a good source of javascripts isn't it? Very useful. I have used and tweaked several from there for various sites.
David
I have that script working near the top of
< www3.sk.sympatico.ca/ajohn >.
How do I add seconds to the clock?
How can I switch my the clock to get it's time from the server rather than the computer that is viewing the page?
david eaton
05-08-2003, 03:52 PM
jes, The alterations to the script for seconds are shown.
As for obtaining the time from the server, I'm afraid that unless you use a server-side cgi or php script, you're out of luck!
Javascript only works as client-side, and can't query the server directly. At least, that's my understanding, there may be someone else on these forums that knows better.
myminutes = mydate.getMinutes();
if (myminutes < 10){
mytime = ":0" + myminutes;
}
else {
mytime = ":" + myminutes;
};
myseconds = mydate.getSeconds();
mysec = ":" +myseconds;
arday = new Array("Sunday","Monday","Tuesday","Wednesday","
Thursday","Friday","Saturday")
armonth = new Array("January ","February ","March ","April ","May ","June
","July ","August ","September ", "October ","November
","December ")
ardate = new Array("0th","1st","2nd","3rd","4th","5th","6th","7th","8th
","9th","10th","11th","12th","13th","14th","15th","16th
","17th","18th","19th","20th","21st","22nd","23rd","24th
","25th","26th","27th","28th","29th","30th","31st");
// rename locale as needed.
var time = ("It is: " + myhours + mytime+ mm + mysec", "
+ arday[myday] +", " + armonth[mymonth] +" "
+ardate[myweekday] + ", " + year+",");
document.write(time);
//-->
</SCRIPT>
David
(edit for wrapping)
My page is http://www3.sk.sympatico.ca/ajohn/
How can I ajust the java script so that the time updates with the PC clock?
david eaton
05-13-2003, 02:49 PM
Jes. Have a look at Javascript Source (http://javascriptsource.com). There are several clock display scripts there. It should be possible to combine one of them with your current script to do what you want.
David
That site gave me what I needed. I have recently returned to it for more code.
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
function countup(yr,m,d) {
var today=new Date();
var todayy=today.getYear();
// Y2K Fix by Isaac Powell
// http://onyx.idbsu.edu/~ipowell
if ((navigator.appName == "Microsoft Internet Explorer") && (todayy < 2000))
todayy="19" + todayy;
if (navigator.appName == "Netscape")
todayy=1900 + todayy;
var todaym=today.getMonth();
var todayd=today.getDate();
var todaystring=montharray[todaym]+" "+todayd+", "+todayy;
var paststring=montharray[m-1]+" "+d+", "+yr;
var difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1);
document.write("OBO employment since May 8,2003 or " + difference + " days.");
}
countup(2003,05,08); // Date in format: (year,month,day)
// End -->
</script>
This does most of what I want it to do. It is the Age Calculator in the "Calculators" area of the Java site, as you can see I have had to modify it a bit. Right now it displays in days. I would like it to display in months (and the remainder in days). The problem is that I don't know quite how to do that since not every month is the same amount. Is it even possible?
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.