jspe377522
MIS
Hi there, I am looking to show the date and time on a web page. I found a javascript on javascript.com and this does pretty much everything but i can not change the font size etc of the date section. I was hoping someone would be able to help.
Cheers
James
Here is the script.
<script language="JavaScript">
<!-- This figures out what day of the week it is, and the date, and year. -->
<!--
s_date = new Date();
var weekDay = "";
selectMonth = new Array(12);
selectMonth[0] = "January";
selectMonth[1] = "February";
selectMonth[2] = "March";
selectMonth[3] = "April";
selectMonth[4] = "May";
selectMonth[5] = "June";
selectMonth[6] = "July";
selectMonth[7] = "August";
selectMonth[8] = "September";
selectMonth[9] = "October";
selectMonth[10] = "November";
selectMonth[11] = "December";
if(s_date.getDay() == 1){
weekDay = "Monday";
}
if(s_date.getDay() == 2){
weekDay = "Tuesday";
}
if(s_date.getDay() == 3){
weekDay = "Wednesday";
}
if(s_date.getDay() == 4){
weekDay = "Thursday";
}
if(s_date.getDay() == 5){
weekDay = "Friday";
}
if(s_date.getDay() == 6){
weekDay = "Saturday";
}
if(s_date.getDay() == 7){
weekDay = "Sunday";
}
if(s_date.getDay() == 0){
weekDay = "Sunday";
}
var setYear = s_date.getYear();
var BName = navigator.appName;
if(BName == "Netscape"
{
var setYear = s_date.getYear() + 1900;
}
document.write(weekDay + ", " + selectMonth[s_date.getMonth()] + " " +
s_date.getDate() + ", " + setYear);
// -->
</script>
<div id=Clock align=Center style="font-family Tahoma; font-size: 28; color:Black"> </div>
<script language = "JavaScript">
//This script was created by Gary Perry
//Email: shadow_chaser@hotmail.com
//Web:
//This script will display a real time clock at the top of your webpage.
//Put this code in the body section of your webpage, and that's all
//there is to it. No images to worry about, nothing, except it
//only works for IE 4 and above.
//Change the color of the font above in the div tag to match your webpage
//colors.
function tick() {
var hours, minutes, seconds, ap;
var intHours, intMinutes, intSeconds;
var today;
today = new Date();
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
switch(intHours){
case 0:
intHours = 12;
hours = intHours+":";
ap = "A.M.";
break;
case 12:
hours = intHours+":";
ap = "P.M.";
break;
case 24:
intHours = 12;
hours = intHours + ":";
ap = "A.M.";
break;
default:
if (intHours > 12)
{
intHours = intHours - 12;
hours = intHours + ":";
ap = "P.M.";
break;
}
if(intHours < 12)
{
hours = intHours + ":";
ap = "A.M.";
}
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = hours+minutes+seconds+ap;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</script>
Cheers
James
Here is the script.
<script language="JavaScript">
<!-- This figures out what day of the week it is, and the date, and year. -->
<!--
s_date = new Date();
var weekDay = "";
selectMonth = new Array(12);
selectMonth[0] = "January";
selectMonth[1] = "February";
selectMonth[2] = "March";
selectMonth[3] = "April";
selectMonth[4] = "May";
selectMonth[5] = "June";
selectMonth[6] = "July";
selectMonth[7] = "August";
selectMonth[8] = "September";
selectMonth[9] = "October";
selectMonth[10] = "November";
selectMonth[11] = "December";
if(s_date.getDay() == 1){
weekDay = "Monday";
}
if(s_date.getDay() == 2){
weekDay = "Tuesday";
}
if(s_date.getDay() == 3){
weekDay = "Wednesday";
}
if(s_date.getDay() == 4){
weekDay = "Thursday";
}
if(s_date.getDay() == 5){
weekDay = "Friday";
}
if(s_date.getDay() == 6){
weekDay = "Saturday";
}
if(s_date.getDay() == 7){
weekDay = "Sunday";
}
if(s_date.getDay() == 0){
weekDay = "Sunday";
}
var setYear = s_date.getYear();
var BName = navigator.appName;
if(BName == "Netscape"
var setYear = s_date.getYear() + 1900;
}
document.write(weekDay + ", " + selectMonth[s_date.getMonth()] + " " +
s_date.getDate() + ", " + setYear);
// -->
</script>
<div id=Clock align=Center style="font-family Tahoma; font-size: 28; color:Black"> </div>
<script language = "JavaScript">
//This script was created by Gary Perry
//Email: shadow_chaser@hotmail.com
//Web:
//This script will display a real time clock at the top of your webpage.
//Put this code in the body section of your webpage, and that's all
//there is to it. No images to worry about, nothing, except it
//only works for IE 4 and above.
//Change the color of the font above in the div tag to match your webpage
//colors.
function tick() {
var hours, minutes, seconds, ap;
var intHours, intMinutes, intSeconds;
var today;
today = new Date();
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
switch(intHours){
case 0:
intHours = 12;
hours = intHours+":";
ap = "A.M.";
break;
case 12:
hours = intHours+":";
ap = "P.M.";
break;
case 24:
intHours = 12;
hours = intHours + ":";
ap = "A.M.";
break;
default:
if (intHours > 12)
{
intHours = intHours - 12;
hours = intHours + ":";
ap = "P.M.";
break;
}
if(intHours < 12)
{
hours = intHours + ":";
ap = "A.M.";
}
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = hours+minutes+seconds+ap;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</script>