JavaScript - An open source scripting language, it allows the creation of dynamic web page content.  Home Web Programming JavaScript Date Time Clock
Your Ad Here

Date Time Clock


 
 
 
 
Click to start the script.

Put this code into your page:

<html>
<head>

<style>
.scroll
{
FONT: 10pt arial;
COLOR: black;
background-color: white;
border: medium none
}
</style>

</head>

<BODY BGCOLOR="#ffffff" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" onload="load_date();">

<br><br><br>
<center>
<form name="bannerform">
<TABLE width="150" border="0" cellpadding="0" cellspacing="0" bgcolor=#F5F4E0>
<tr>
<td colspan=3><img src=images/spacer.gif height=10></td>
</tr>
<tr>
<td><img src=images/spacer.gif width=10></td>
<td><input type="text" name="clock1" size="38" class=scroll onfocus="blur()"></td>
<td><img src=images/spacer.gif width=10></td>
</tr>
<tr>
<td colspan=3><img src=images/spacer.gif height=10></td>
</tr>
</table>
</form>
</center>

</body>

<script>
<!--

var dayarray=new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
var montharray=new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Augt", "Sep", "Oct", "Nov", "Dec")

function getthedate()
{
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12}

if (hours==0){
hours=12}

if (minutes<=9){
minutes="0"+minutes}

if (seconds<=9){
seconds="0"+seconds}

//change font size here
var ddate=" "+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn +" "
document.bannerform.clock1.value=ddate
}

if (!document.all&&!document.getElementById)
getthedate()

function load_date()
{
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}

// -->
</script>
</html>



Author's URL: Mark Pearson
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

Web programming � everything from the basics of visual design and architecture to the specifics of applications, graphics, and scripting. More Web Programming: Most Popular Materials | Fresh Materials | More JavaScript Tutorials at LearnPHP.org

Add comments to "Date Time Clock"

Only registered users can write comment

No comments yet...