place below code - inside the script tags
function startTime(){
//To print the Month/Date
var now=new Date();
var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
document.getElementById('ciDate').innerHTML = monthname[now.getMonth()] + " " + now.getDate();
var today=new Date();
var h=today.getHours()
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10 m=checkTime(m); s=checkTime(s); document.getElementById('gmtTime').innerHTML = h+":"+m+":"+s; t=setTimeout('startTime()',500); } function checkTime(i){ if (i<10){ i = "0" + i; } return i; }
onload call the startTime() (java script method)
place below code in inside body tags
Date: open span tag id="ciDate" close span tag, Time : open span id="gmtTime" end span tag.
Out put : Date: Jan 19 Time : 12:12:50 (Time will change dynamically)
No comments:
Post a Comment