Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
System Time using JavaScript
WhatsApp
Kaushik S
Sep 17
2015
1
k
0
0
<!DOCTYPE html>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head runat=
"server"
>
<title></title>
<style type=
"text/css"
>
.timer {
border-width: 1px;
text-align: center;
font-family: Algerian;
background-color: aqua;
width: 130px;
border-style: solid;
}
</style>
</head>
<body>
<form id=
"form1"
runat=
"server"
>
<div id=
"timeclock"
class
=
"timer"
></div>
</form>
<script type=
"text/javascript"
>
function getTimeFunc() {
//debugger;
var timeclock = document.getElementById(
"timeclock"
);
timeclock.innerHTML =
""
;
var getcurrdate =
new
Date();
var hr = parseInt(Math.floor(getcurrdate.getHours()));
var mi = parseInt( Math.floor(getcurrdate.getMinutes()));
var sc = parseInt(Math.floor(getcurrdate.getSeconds()));
var meridian =
"AM"
if
(hr > 12);
{
hr = hr - 12;
meridian=
"PM"
}
if
(hr == 0) {
hr =
"0"
;
}
if
(hr < 10)
{
hr =
"0"
+ hr;
}
if
(mi < 10) {
mi =
"0"
+ mi;
}
if
(sc < 10) {
sc =
"0"
+ sc;
}
var totalTime = hr +
":"
+ mi +
":"
+ sc +
" "
+ meridian;
timeclock.innerHTML =totalTime;
setTimeout(getTimeFunc, 1000);
}
getTimeFunc();
</script>
</body>
</html>
System Time
JavaScript
Up Next
System Time using JavaScript