Football fun
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Title Bar Date and Time Display

Go down

Title Bar Date and Time Display Empty Title Bar Date and Time Display

Post  True Blue Sun Oct 16, 2011 9:40 am

Description:
Use the bold text code below to display today's date and current time on your web page.

Place the code below between the <HEAD> and </HEAD> tags within the HTML page where you want the date to appear.

<script language="JavaScript">
<!--
function resetIt() {

// Calculate Time

var timerID = null;
var timerRunning = false;

if(timerRunning)
clearTimeout(timerID);
timerRunning = false;

// getTime
var timeNow = new Date();
var hours = timeNow.getHours();
var minutes = timeNow.getMinutes();
var seconds = timeNow.getSeconds();
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue = ((timeValue <10)? "0":"") + timeValue
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " PM" : " AM"
timerID = setTimeout("resetIt()",100);
timerRunning = true;


// getDate
var dateNow = new Date();
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var date = ((dateNow.getDate()<10) ? "0" : "")+ dateNow.getDate();
function y2k(number){return (number < 1000) ? number + 1900 : number;}

// compileIt
today = timeValue + " " + days[dateNow.getDay()] + " " +
months[dateNow.getMonth()] + ", " +
date + " " +
(y2k(dateNow.getYear()));

if(document.all || document.getElementById){ // Browser Check
document.title = today.toString();
}else{
self.status = today.toString(); // Default to status.
}
}

resetIt();

//-->
</script>




True Blue
True Blue

Posts : 160
Join date : 2011-09-29
Location : N.Ireland

https://footballfun.forumotion.co.uk

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum