Breaking News

Date, Time show By javascript on webPage , Update time and Date

Hi friends

if you searching date, time and update date, time than this javascript code will help u and  I am  soure it perfact to you and

example:-

Date= Tuesday,April 10,2012 Time= 12:51:34

if you have any query  please mail me ................... Thanks

 

 

 

<html>

<head>

<title>:: Date Time Watch Javascript Code::</title>

 

 

</head>

<body onLoad="Watch()">

<script type="text/javascript">

var dayary = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")

var mthary = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")

function gettodate() {

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 cdate = "<small><font color='515252' face='arial' size='2'><b> Date= " + dayary[day] + "," + mthary[month] + " " + daym + "," + year + " Time= " + hours + ":" + minutes + ":" + seconds + " " + dn

+ "</b></font></small>"

if (document.all)

document.all.clock.innerHTML = cdate

else if (document.getElementById)

document.getElementById("showDate").innerHTML = cdate

else

document.write(cdate)

}

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

gettodate()

function Watch() {

if (document.all || document.getElementById)

setInterval("gettodate()", 1000)

}

</script>

<span id="clock"></span>

</body>

</html>

No comments