473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Current Time

JCO
The function below should work, but I would like to know how to get the to
display at a specific area on a website. Can sombody tell me how to make
use of this function. I have it pasted in the right area of my website
(head section) and I'm sure it is loading when the page loads, but not sure
how to execute it.

function getTime()
{
var tNow = new Date()
return tNow.toLocaleTimeString()
}

Thanks

Jul 23 '05 #1
4 1743
" JCO" <jo********@hotmail.com> wrote in message
news:c7Wve.164$Iv6.96@trnddc03...
The function below should work, but I would like to know how to get the to
display at a specific area on a website. Can sombody tell me how to make
use of this function. I have it pasted in the right area of my website
(head section) and I'm sure it is loading when the page loads, but not sure how to execute it.

function getTime()
{
var tNow = new Date()
return tNow.toLocaleTimeString()
}

Thanks

Will this help? Watch for word-wrap.

<html>
<head>
<title>time_js.htm</title>
<script type="text/javascript">
function getTime() {
var tNow = new Date();
document.getElementById("time").innerHTML = tNow.toLocaleTimeString();
}
</script>
</head>
<body onload="getTime()">
<hr>
<span id="time"></span>
<hr>
</body>
</html>
Jul 23 '05 #2
McKirahan wrote on 27 jun 2005 in comp.lang.javascript:
Will this help? Watch for word-wrap.

<html>
<head>
<title>time_js.htm</title>
<script type="text/javascript">
function getTime() {
var tNow = new Date();
document.getElementById("time").innerHTML =
tNow.toLocaleTimeString();
}
</script>
</head>
<body onload="getTime()">
<hr>
<span id="time"></span>
<hr>
</body>
</html>


Simplify to:

<html>
<head>
<title>time_js.htm</title>
</head>
<body>
<hr>
<script type="text/javascript">
document.write(new Date().toLocaleTimeString());
</script>
<hr>
</body>
</html>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #3
JCO
Yes this works perfect.
Thanks so much.

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:Tc********************@comcast.com...
" JCO" <jo********@hotmail.com> wrote in message
news:c7Wve.164$Iv6.96@trnddc03...
The function below should work, but I would like to know how to get the to display at a specific area on a website. Can sombody tell me how to make use of this function. I have it pasted in the right area of my website
(head section) and I'm sure it is loading when the page loads, but not

sure
how to execute it.

function getTime()
{
var tNow = new Date()
return tNow.toLocaleTimeString()
}

Thanks

Will this help? Watch for word-wrap.

<html>
<head>
<title>time_js.htm</title>
<script type="text/javascript">
function getTime() {
var tNow = new Date();
document.getElementById("time").innerHTML = tNow.toLocaleTimeString();
}
</script>
</head>
<body onload="getTime()">
<hr>
<span id="time"></span>
<hr>
</body>
</html>

Jul 23 '05 #4
JRS: In article <Tc********************@comcast.com>, dated Mon, 27 Jun
2005 12:10:25, seen in news:comp.lang.javascript, McKirahan
<Ne**@McKirahan.com> posted :
function getTime() {
var tNow = new Date();
document.getElementById("time").innerHTML = tNow.toLocaleTimeString();
}


Method toLocaleTimeString, though in ECMA-262, seems to be comparatively
recent; getElementById is also recent; the OP should be warned that your
code will not work in all browsers.

Since getTime is a method of the Date object, it seems unwise to re-use
that identifier for a distinct purpose.

The OP should note that "Locale" forms are not necessarily correctly
localised in all systems, and some may be ambiguous. IMHO, it's better
to code an unambiguous ISO 8601 form; no-one can misunderstand it, and
it annoys the rednecks.

Does anyone know if a Web page listing the versions at which the more
recent Date Object Methods were introduced in various browsers?

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Chris | last post by:
Sorry, This should be simple, but brain is hurting... How do I convert a Current Time to a Decimal 6,0 (HMS)? There must be a cleaner way then this: Insert into Table Values Dec(...
2
by: MarthaR | last post by:
I am trying to add the current time to a field when the user clicks on the toggle button next to the field. I am getting a time of 12:00:00 AM each time I click the button. How do I get a...
18
by: Tim Quon | last post by:
Hi I need to print the current time. I found an example where this is done as followed: long *mytime; time(mytime); printf("time: %s", ascitime(mytime); But this doesn't work and prints...
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
7
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
4
by: Gary Wessle | last post by:
Hi I am not getting current time with this program, what am I doing wrong? #include <ctime> #include <iostream> using namespace std; #define P(x) cout << #x " = " << (x) << "\n";
3
by: Mark Ingram | last post by:
Hi, I'd like to know the best way of checking the current time during a demonstration product. At the minute i store the first run date, then compare that to the system time, but obviously a user...
11
by: greg | last post by:
Hi all, Is there a way to get the current theme name at design time? I'm trying to write a custom control for which I need to use images from the current theme. I have asigned a theme to the...
6
by: trytobreak | last post by:
Hi All, I am a network administrator in a fairly large software company and I would like to write myself a small utility, which would connect (one by one) to all machines on the network and get...
7
by: Damir | last post by:
I have a situation on a DB server where the "current timestamp" command shows the actual system time offset by one hour, which has never been noticed before?!? The DB2 is V9.1 (FP03), running on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.