Home
|
Ask Question
|
Interview Questions
|
Tech FAQ
s
|
Engineering
|
Company
|
Geek Forums
|
Interview Coaching
|
Online Quiz
|
Interview eBook
Code Base
Submit Code
Back
Oracle
PHP
Java
ASP.NET
C#
Delphi
VB.NET
Perl
ColdFusion
SQL Server
MySQL
C
C++
UNIX
AJAX
Flash
HTML
CSS
Java Script
VB Script
XML
Python
MS Access
MainFrame
HTML Code Base
•
Clock
•
Form Designer
•
RTF 2 HTML Converter
Code Samples
HTML
Clock
Code Resource
Author:
Nidhi Saxena
Difficulty Level
: Intermediate
Published:
11th Feb 2011
Read:
1942 times
Filed in:
HTML
Add Comment
Sponsored Links
Clock using system time in HTML page
Sample Code
<html>
<head>
<script
type
=
"text/javascript"
>
function startTime()
{
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
(
'txt'
)
.innerHTML
=
h+
":"
+m+
":"
+
s
;
t
=
setTimeout
(
'startTime()'
,
500
)
;
}
function checkTime
(
i
)
{
if
(
i<
10
)
{
i
=
"0"
+
i
;
}
return
i
;
}
<
/
script>
<
/
head>
<body
onload
=
"startTime()"
>
<div
id
=
"txt"
>
<
/
div>
<
/
body>
<
/
html>
Copyright GeekInterview.com
Next Article:
Form Designer
Latest Code Samples
♦
Clock
♦
Form Designer
♦
RTF 2 HTML Converter
Popular Code Samples
♦
Form Designer
♦
RTF 2 HTML Converter
♦
Clock
Related Code Samples
Post Your Comment:
Members Please Login
Your Name:
*
e-mail ID:
(required for notification)
*
Image Verification:
Subscribe
Popular Coders
#
Coder Name
Hits
1.
RyanJames
4063
2.
chowsys
3179
3.
Nidhi Saxena
1943
Active Coders
#
Coder Name
Codes
1.
chowsys
1
2.
RyanJames
1
3.
Nidhi Saxena
1
Refined Tags
Copyright © 2012 GeekInterview.com | All Rights Reserved