IF you want Date and Time in Dynamic Run on web Page and also the Login time i.e the clock starts from the start of java function scipt and also gives how many hours,minutes and seconds you are online in the Application or a Particular web Page For this just call the javascript function in the html body load.
<script type="text/javascript">
var second;
var first = new Date;
function date_time() {
var id = 'Label1'
date = new Date;
second = date.getTime();
year = date.getFullYear();
month = date.getMonth();
months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
d = date.getDate();
day = date.getDay();
days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
h = date.getHours();
if (h < 10) {
h = "0" + h;
}
m = date.getMinutes();
if (m < 10) {
m = "0" + m;
//min = min+1;
}
s = date.getSeconds();
if (s < 10) {
s = "0" + s;
//sec = sec+1;
}
var timeDiff = second - first.getTime();
var hours = Math.floor(timeDiff / (1000 * 60 * 60));
timeDiff -= hours * (1000 * 60 * 60);
var mins = Math.floor(timeDiff / (1000 * 60));
timeDiff -= mins * (1000 * 60);
var secs = Math.floor(timeDiff / 1000)
timeDiff -= secs * 1000;
result = 'LoginTime(HH:MM:SS) ' + hours + ':' + mins + ':' + secs + ' ' + days[day] + ' ' + months[month] + ' ' + d + ' ' + year + ' Clock(24hr): ' + h + ':' + m + ':' + s;
document.getElementById(id).innerHTML = result;
setTimeout('date_time("' + id + '");', '1000');
return true;
}
By Santosh Kumar Murarkar