Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

JavaScript Display Current Time on Webpage or Website without Refreshing the Page

Oct 14, 2012
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.

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); // Here 1000(milliseconds) means one 1 Sec  
}
</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.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

11 comments :

Anonymous said...

Nice

Unknown said...

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

Unknown said...

hi suresh ji!!
your all articles are helping me lot.

thank you!!

Naveen Baghel said...

use full example.

Anonymous said...

Great Logic

Anonymous said...

Please put 4 tier Architecture Examples...

Akram said...

Very Nice Explanation given by Suresh Ji!!!!!!

Anonymous said...

great web site suresh you r brilliant

Anonymous said...

good one u give more current day ,month and year

Anonymous said...

I used the code on my asp webpage but it does show and the IDE shows no error, im using MS Visual Studio

Grab Deals said...

can u tell me how to add current month and year in title and it should be automatically updated

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.