Digital Clock Using JavaScript:
Java Script:
-------------------
<script>
function digclock() {
var d = new Date()
var t = d.toLocaleTimeString()
var hr = t.substring(0, 2)
var min = t.substring(3, 5)
var sec = t.substring(6, 8)
var time
if (hr >= 12) {
time = (hr - 12) + ':' + min + ':' + sec + ' ' + 'PM'
}
else {
time = hr + ':' + min + ':' + sec + ' ' + 'AM'
}
document.getElementById('<%= divTimer.ClientID%>').innerHTML = time
}
setInterval(function () { digclock() }, 1000)
</script>
HTML:
----------
<div id="divTimer" runat="server" style="font-size:small; color:white;" ></div>
Java Script:
-------------------
<script>
function digclock() {
var d = new Date()
var t = d.toLocaleTimeString()
var hr = t.substring(0, 2)
var min = t.substring(3, 5)
var sec = t.substring(6, 8)
var time
if (hr >= 12) {
time = (hr - 12) + ':' + min + ':' + sec + ' ' + 'PM'
}
else {
time = hr + ':' + min + ':' + sec + ' ' + 'AM'
}
document.getElementById('<%= divTimer.ClientID%>').innerHTML = time
}
setInterval(function () { digclock() }, 1000)
</script>
HTML:
----------
<div id="divTimer" runat="server" style="font-size:small; color:white;" ></div>
Nice Article
ReplyDeleteHi...
ReplyDelete