App4: A simple digital clock

<!–

A digital clock made by javascript,css2,html.Watch it out, it is so much easy

–>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
<script type=”text/javascript”>

function time()
{
var date = new Date();
var h = date.getHours();
var m = date.getMinutes();
var s = date.getSeconds();

var a = ‘AM’;
if((h*60)-(12*60)>=0)
var a = ‘PM’;
document.getElementById(‘clock’).innerHTML=(h-12)+’:’+zero_add(m)+’:’+zero_add(s)+'<sub>’+a+'</sub>’;

setTimeout(‘time()’,500);

}
function zero_add(t)
{
if(t<10)
{
t =’0’+t;
}
return t;

}

</script>

<style type=”text/css”>

#clock
{
height:40px;
width:150px;
background-color:#0F6;
font-size:36px;
color:#06F;
border:5px groove #03F;
padding:5px 15px;
}

</style>
</head>

<body onload=”time()”>
<div id=”clock”></div>
</body>
</html>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s