Introduction:
Here I will explain how to show or display current time on webpage or website in JavaScript.
Description:
In previous articles I explained JQuery display Current Time on WebPage, Get Current Datetime, Disable right click on image and many articles relating to JQuery and JavaScript. Now I will explain how to show or display current time on webpage using jQuery.
In previous articles I explained JQuery display Current Time on WebPage, Get Current Datetime, Disable right click on image and many articles relating to JQuery and JavaScript. Now I will explain how to show or display current time on webpage using jQuery.
To display current time on webpage or website using JavaScript
we
need to write the following code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>JavaScript display current time on webpage</title>
<script type="text/javascript">
function ShowCurrentTime() {
var dt = new Date();
document.getElementById("lblTime").innerHTML =
dt.toLocaleTimeString();
window.setTimeout("ShowCurrentTime()", 1000);
}
</script>
</head>
<body onload="ShowCurrentTime()">
<form id="form1"
runat="server">
<div>
JavaScript Display current time second by
second.
<label id="lblTime"
style=" font-weight:bold"></label>
</div>
</form>
</body>
</html>
|
Demo
JavaScript Display current time second by second:
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
11 comments :
Nice
hi suresh i am great fan to u r website...u r examples are so much use full for me thank you for sharing all...plz share the mvc3 related posts plz
hi suresh ji!!
your all articles are helping me lot.
thank you!!
use full example.
Great Logic
Please put 4 tier Architecture Examples...
Very Nice Explanation given by Suresh Ji!!!!!!
great web site suresh you r brilliant
good one u give more current day ,month and year
I used the code on my asp webpage but it does show and the IDE shows no error, im using MS Visual Studio
can u tell me how to add current month and year in title and it should be automatically updated
Note: Only a member of this blog may post a comment.