function date_time(id)
{
date = new Date;
year = date.getFullYear();
month = date.getMonth();
months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'Jully', 'August', 'September', 'October', 'November', 'December');
d = date.getDate();
day = date.getDay();
days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
h = date.getHours();
suffix = "AM";
if (h >= 12) {
suffix = "PM";
h = h - 12;
}
if (h == 0) {
h = 12;
}
m = date.getMinutes();
if(m<10)
{
m = "0"+m;
}
s = date.getSeconds();
if(s<10)
{
s = "0"+s;
}
result=''+days[day]+', '+months[month]+' 0'+d+', '+year+' '+'Time : '+h+':'+m+':'+s+' '+suffix;
document.getElementById(id).innerHTML = result;
setTimeout('date_time("'+id+'");','1000');
return true;
}
<td colspan="3" style="width:340px">
<span id="date_time" class="date_time"></span>
<script type="text/javascript">window.onload = date_time('date_time');</script>
</td>
{
date = new Date;
year = date.getFullYear();
month = date.getMonth();
months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'Jully', 'August', 'September', 'October', 'November', 'December');
d = date.getDate();
day = date.getDay();
days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
h = date.getHours();
suffix = "AM";
if (h >= 12) {
suffix = "PM";
h = h - 12;
}
if (h == 0) {
h = 12;
}
m = date.getMinutes();
if(m<10)
{
m = "0"+m;
}
s = date.getSeconds();
if(s<10)
{
s = "0"+s;
}
result=''+days[day]+', '+months[month]+' 0'+d+', '+year+' '+'Time : '+h+':'+m+':'+s+' '+suffix;
document.getElementById(id).innerHTML = result;
setTimeout('date_time("'+id+'");','1000');
return true;
}
<td colspan="3" style="width:340px">
<span id="date_time" class="date_time"></span>
<script type="text/javascript">window.onload = date_time('date_time');</script>
</td>
No comments:
Post a Comment