Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Display current time on aspx page

Posted on 2006-07-21
6
Medium Priority
?
1,185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 23

Expert Comment

by:apresto
ID: 17154143
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
ID: 17154147
Here is another useful page about date formatting:

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

Accepted Solution

by:
Pravin Asar earned 1000 total points
ID: 17154322
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Mike_Stevens
ID: 17155167
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 1000 total points
ID: 17155694
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 29

Expert Comment

by:Pravin Asar
ID: 17155708
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

610 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