Solved

Display current time on aspx page

Posted on 2006-07-21
6
1,171 Views
Last Modified: 2012-06-21
I need to display the current date and time on an aspx webform.   I dont know anything abut javascript and hoping someone can help me.

I need to display the date and time, both in the long format: "Friday July 21, 2006 8:00:01 am"


Can somebody lend me some sample code?

Thanks
0
Comment
Question by:Mike_Stevens
6 Comments
 
LVL 23

Expert Comment

by:apresto
Comment Utility
Hi Mike_Stevens,

This might help:

http://www.js-examples.com/page/javascripts__example.html?run=971

you might need to edit slightly

Apresto
0
 
LVL 23

Expert Comment

by:apresto
Comment Utility
Here is another useful page about date formatting:

http://www.mattkruse.com/javascript/date/
0
 
LVL 28

Accepted Solution

by:
Pravin Asar earned 250 total points
Comment Utility
These few lines of code will do the job.


<script language="javascript">
function printCurrentTime () {
documen.write ((new Date()).toString());
}
</script>

<div>Current Time : <script language="javascript">printCurrentTime();</script></div>
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:Mike_Stevens
Comment Utility
The works fine to display the date but i was hoping to have it click off the seconds on the page
0
 
LVL 19

Assisted Solution

by:nschafer
nschafer earned 250 total points
Comment Utility
Hi Mike_Stevens,

Building on pravinasar's code:

<html>
<head>
<title></title>
<script language="javascript">
function printCurrentTime () {
document.getElementById("time").innerHTML = "Current Time: " + new Date().toString();
}
setInterval("printCurrentTime();",1000);
</script>
</head>
<body>
<div id="time"></div>
</body>
</html>


Hope this helps,
Neal.
0
 
LVL 28

Expert Comment

by:Pravin Asar
Comment Utility
To display second,

use this one
<script language="javascript">
function printCurrentTime () {
document.write ((new Date()).toLocaleString());
}
</script>

<div>Current Time : <script language="javascript">printCurrentTime();</script></div>

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now