473,372 Members | 1,055 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,372 software developers and data experts.

displaying the time

Hi Gurus

Is it possible to display the time on a site using javascript. I want to
show visitors the current time in New Zealand, but the javascript that I use
actually displays the time on the users computer (i.e. completely useless).

Any ideas greatly appreciated

Thanks in advance

- Nicolaas
Jul 23 '05 #1
7 1571
On Tue, 5 Oct 2004 11:49:10 +1300, WindAndWaves <ac****@ngaru.com> wrote:
Is it possible to display the time on a site using javascript. I want
to show visitors the current time in New Zealand, but the javascript
that I use actually displays the time on the users computer (i.e.
completely useless).


You can get UTC (GMT) time using the various UTC Date methods and adjust
the result with the appropriate offset. However, that depends on the
accuracy of the user's computer, so it might be just as useless.

You could always link to
<URL:http://www.worldtimeserver.com/?locationid=NZ>. I don't know exactly
how accurate they are.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2
"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:opsfd0f5iix13kvk@atlantis...
On Tue, 5 Oct 2004 11:49:10 +1300, WindAndWaves <ac****@ngaru.com> wrote:
Is it possible to display the time on a site using javascript. I want
to show visitors the current time in New Zealand, but the javascript
that I use actually displays the time on the users computer (i.e.
completely useless).


You can get UTC (GMT) time using the various UTC Date methods and adjust
the result with the appropriate offset. However, that depends on the
accuracy of the user's computer, so it might be just as useless.

You could always link to
<URL:http://www.worldtimeserver.com/?locationid=NZ>. I don't know exactly
how accurate they are.

Hi Mike

I think I am going to use that link and perhaps see if I can use PHP instead
of Java. That client-side really is not useful here. Thank you for that
link though, that is great. I actually downloaded the program that they
offer there to keep your clock up-to-date, as my clock does not seem to keep
up.

Thank you

Nicolaas
Jul 23 '05 #3
JRS: In article <mi*******************@news.xtra.co.nz>, dated Tue,
5 Oct 2004 11:49:10, seen in news:comp.lang.javascript, WindAndWaves
<ac****@ngaru.com> posted :

Is it possible to display the time on a site using javascript. I want to
show visitors the current time in New Zealand, but the javascript that I use
actually displays the time on the users computer (i.e. completely useless).


Read the newsgroup FAQ, posted here regularly and via sig line 2.
With care, that will lead you to <URL:http://www.merlyn.demon.co.uk/
js-date5.htm#Demo> ; select the fourth entry in the drop-down, then
Run. Check the TZ string.

Or enter Wellington NZST-12NZDT,M10.1.0/2:00,M3.3.0/2:00 as a
line in <URL:http://www.merlyn.demon.co.uk/js-date5.htm#SLHD>

Check the change dates & times.

RSVP any corrections.

The code can be simplified for a specific case, but then you are in
trouble if the NZ rules change.

If you're prepared to re-upload your page at the critical moment
each Spring and Autumn, of course, you only have to add 12 or 13
hours to GMT.

--
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 #4

"Dr John Stockton" <sp**@merlyn.demon.co.uk> wrote in message
news:kB**************@merlyn.demon.co.uk...
JRS: In article <mi*******************@news.xtra.co.nz>, dated Tue,
5 Oct 2004 11:49:10, seen in news:comp.lang.javascript, WindAndWaves
<ac****@ngaru.com> posted :

Is it possible to display the time on a site using javascript. I want to
show visitors the current time in New Zealand, but the javascript that I useactually displays the time on the users computer (i.e. completely
useless).
Read the newsgroup FAQ, posted here regularly and via sig line 2.
With care, that will lead you to <URL:http://www.merlyn.demon.co.uk/
js-date5.htm#Demo> ; select the fourth entry in the drop-down, then
Run. Check the TZ string.

Or enter Wellington NZST-12NZDT,M10.1.0/2:00,M3.3.0/2:00 as a
line in <URL:http://www.merlyn.demon.co.uk/js-date5.htm#SLHD>

Check the change dates & times.

RSVP any corrections.

The code can be simplified for a specific case, but then you are in
trouble if the NZ rules change.

If you're prepared to re-upload your page at the critical moment
each Spring and Autumn, of course, you only have to add 12 or 13
hours to GMT.

--
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.

Dear John

I had a really good look at your page, but it looks rather technical! More
the kind of thing for a PhD..

Anyway, I am going to have a crack at it.

Thank you.
Jul 23 '05 #5
Is there a routine anywhere, not necessarily javascript, that can be
used to directly access a time server and display time, using
parameters to adjust for time zone, on a web site without going through
a third-party site?

--
Dennis Marks
http://www.dcs-chico.com/~denmarks/
Mail to the return email address is bounced.
Go to web site for active email address.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 23 '05 #6
JRS: In article <10*************************@dcsi.net>, dated Sun, 10
Oct 2004 09:05:03, seen in news:comp.lang.javascript, Dennis M. Marks
<de******@dcsi.net> posted :
Is there a routine anywhere, not necessarily javascript, that can be
used to directly access a time server and display time, using
parameters to adjust for time zone, on a web site without going through
a third-party site?


Yes, site www.heavens-above.com uses one, IIRC. Surely there are other
sites showing the capability.

It is sufficient to take code to access UTC/GMT from a server, and to
apply to its result the algorithms on my site, translated into language-
of-choice. The algorithms can be re-invented; and may be in the
libraries of some languages. Do not, however, trust any code written in
countries with a historical tradition of non-compliance with accepted
standards; if they can get it wrong, they will.

Allowing for time zone is trivial; one merely uses
setUTCHours(getUTCHours() + N) . Allowing for summer time transitions
given by reasonable rules is not too difficult. Allowing for the
decisions of politicians on time changes would require continuing
effort.

I don't know ASP, PHP, etc. - others here do - but ISTM that you could
use such technologies to deliver web-server time (which *should* be
time-server synchronised) with the page, which could determine the local
clock error, and then use my code, or similar, to display corrected
local time. Let the page self-refresh at intervals, to take out local
clock drift.

You don't say how the time zone required is to be determined; author's
choice, reader's choice, reader's location, ?.

One could use the time server to determine the current error of the
user's local GMT, which will (if the user is correctly configured) be
the same as the current error of the user's local local time (except
briefly at the summer/winter transitions), and can be used to correct
the latter for display.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 23 '05 #7
In article <MA**************@merlyn.demon.co.uk>, Dr John Stockton
<sp**@merlyn.demon.co.uk> wrote:
JRS: In article <10*************************@dcsi.net>, dated Sun, 10
Oct 2004 09:05:03, seen in news:comp.lang.javascript, Dennis M. Marks
<de******@dcsi.net> posted :
Is there a routine anywhere, not necessarily javascript, that can be
used to directly access a time server and display time, using
parameters to adjust for time zone, on a web site without going through
a third-party site?


Yes, site www.heavens-above.com uses one, IIRC. Surely there are other
sites showing the capability.


It seems as though the time is generated at the server since it is
already within the source of the page when I look at it. I should have
made it clear that I was looking for a non-server method. Maybe there
is somewhere in the site that the time is generated from code within a
page. If so, please point it out.

Is there a way to link to a time server, have data returned, and then
manipulate the returned data with code within a web page?

I do not have any current plans to use the code. I am just interested
in how and if it can be done at the user level.

--
Dennis Marks
http://www.dcs-chico.com/~denmarks/
Mail to the return email address is bounced.
Go to web site for active email address.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 23 '05 #8

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

Similar topics

5
by: Mystery | last post by:
Can anyone point me to a script that will allow me to list x number of records per page and give me a page selector and information like the one in the subject header? Thanks.
8
by: euang | last post by:
Hi, I have been using access 2000 for two years on WINDOWS NT to display dynamic aweb page using ASP My ISP has now changed to Windows 2003, and I am having major problems displaying...
1
by: Dave Posh | last post by:
I seem to be having a problem displaying time stored in mysql. The format stored in the database is 13:15:05. The database data type is time. I'm using asp vbscript and sql to retrieve the time...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
1
by: David Lozzi | last post by:
Hello, I'm wondering whats the best method to use for displaying several photos' thumbnails. One method I know is to dynamically resize the photo at the time the page is loaded. What does this...
4
by: MrL8Knight | last post by:
Hello, I am trying to build a simple php form based shopping cart using a cookie with arrays. I need to use 1 cookie because each order will have over 20 items. With that said, I realize I need to...
11
by: dba | last post by:
Have been displaying data from database using html for some time but just recently trying to display data back to "form". Can't find answer. <form method="post" action="<?php echo $PHP_SELF;?>">...
0
by: Steve | last post by:
The approach in this thread looks wrong to me considering your example. Your example shows you have random time periods between 6AM and 6 PM for appointments. Appointment 1 is 1-1/2 hour,...
1
by: MLH | last post by:
Without explicitly typing each global var into code module for displaying, does VBA have any facility for determining what GV's are defined in a given database? You know, something like a Set or...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.