By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

Date/Time Question

P: n/a
Many scripts and calendars call client side system time in order to
make presentations.

However, the client's time may be improperly set, if set at all,
and/or the relevant time may be from another time zone.

It would be of great value if the time of some central source could be
drawn, in the form of a ".js" file, into the script to avoid
dependence on the client's date/time.

Even if such a central source produced a new file, extention ".js"
with such simple text as Date(,,) with the proper attributes of year,
month, day, hour and minute, a new file produced every 5 minutes (for
example), there would be a great many applications.

Does anyone know of such a source?

Is anyone interested in donating/hosting such a utility?
Even just a once every half hour genetor would have merit.

Please reply to ma*********@eastontario.com (remove the _NOSPAM_ part)
Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Gord" <no*@eastontario.com> wrote in message
news:31**************************@posting.google.c om...
Many scripts and calendars call client side system time in order to
make presentations.

However, the client's time may be improperly set, if set at all,
and/or the relevant time may be from another time zone.

It would be of great value if the time of some central source could be
drawn, in the form of a ".js" file, into the script to avoid
dependence on the client's date/time.

Even if such a central source produced a new file, extention ".js"
with such simple text as Date(,,) with the proper attributes of year,
month, day, hour and minute, a new file produced every 5 minutes (for
example), there would be a great many applications.

Does anyone know of such a source?

Is anyone interested in donating/hosting such a utility?
Even just a once every half hour genetor would have merit.

Please reply to ma*********@eastontario.com (remove the _NOSPAM_ part)

The following uses ASP to return the current server-side timestamp; (watch
for word-wrap):

<% @Language="VBScript" %>
<% Option Explicit
Function TimeStamp()
'*
'* Timestamp() returns "ccyymmddhhnnss"
'*
Dim arrNOW(6)
arrNOW(0) = Now()
arrNOW(1) = DatePart("yyyy",arrNOW(0))
arrNOW(2) = DatePart("m",arrNOW(0))
arrNOW(3) = DatePart("d",arrNOW(0))
arrNOW(4) = DatePart("h",arrNOW(0))
arrNOW(5) = DatePart("n",arrNOW(0))
arrNOW(6) = DatePart("s",arrNOW(0))
Dim intNOW
Dim strNOW
strNOW = ""
'*
For intNOW = 1 To UBound(arrNOW)
If (arrNOW(intNOW) < 10) Then
arrNOW(intNOW) = "0" & arrNOW(intNOW)
End If
strNOW = strNOW & arrNOW(intNOW)
Next
'*
TimeStamp = strNOW
End Function
%>
<html>
<head>
<title>TimeStamp.asp</title>
</head>
<body>
<%=TimeStamp()%>
</body>
</html>
Jul 20 '05 #2

P: n/a
JRS: In article <31**************************@posting.google.com >, seen
in news:comp.lang.javascript, Gord <no*@eastontario.com> posted at Thu,
18 Dec 2003 08:06:36 :-
Many scripts and calendars call client side system time in order to
make presentations.

However, the client's time may be improperly set, if set at all,
and/or the relevant time may be from another time zone.

It would be of great value if the time of some central source could be
drawn, in the form of a ".js" file, into the script to avoid
dependence on the client's date/time.

The returned date/time needs to be GMT. For us, the best form would be
as a value of milliseconds since 1970-01-01 00:00:00 GMT, which can be
directly applied : var T = new Date(Number) or new Date(+String) .

There is no need for a _central_ source; reliable time, sufficiently
accurately, is available to servers worldwide.

Converting time between zones is AFAICS a solved problem, provided that
a valid TZ string can be supplied for each remote location, and that the
zone of a remote time us unambiguously indicated. See far below.

QHAH.
In article <5wkEb.80063$8y1.286217@attbi_s52>, seen in
news:comp.lang.javascript, McKirahan <Ne**@McKirahan.com> posted at Thu,
18 Dec 2003 16:23:29 :-
<% @Language="VBScript" %>


Which can be reduced using

s = Now
y = year(s) : ... : s = seconds(s)
TimeStamp = ((((Y*100+M)*100+D)*100+h)*100+n)*100+s

assuming this VBscript is like what I have.
--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for 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 20 '05 #3

P: n/a
Gord wrote on 18 Dec 2003 at Thu, 18 Dec 2003 16:06:36 GMT:
Many scripts and calendars call client side system time in order
to make presentations.

However, the client's time may be improperly set, if set at all,
and/or the relevant time may be from another time zone.

It would be of great value if the time of some central source
could be drawn, in the form of a ".js" file, into the script to
avoid dependence on the client's date/time.
The best central source is the Time server network. However,
JavaScript is unable to access such a resource. A Java applet or a
server-side language (that includes a Time protocol or Sockets
library) could with a bit of effort.
Please reply to ma*********@eastontario.com (remove the _NOSPAM_
part)


Please read the FAQ for this group (http://jibbering.com/faq/),
particularly the sixth paragraph of article 2.3.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #4

P: n/a
In article <Eo**************@merlyn.demon.co.uk>, Dr John Stockton
<sp**@merlyn.demon.co.uk> writes:

<--snip-->
It would be of great value if the time of some central source could be
drawn, in the form of a ".js" file, into the script to avoid
dependence on the client's date/time.

The returned date/time needs to be GMT. For us, the best form would be
as a value of milliseconds since 1970-01-01 00:00:00 GMT, which can be
directly applied : var T = new Date(Number) or new Date(+String) .


Doesn't all of it still depend on the clients clock being set correctly?
Meaning, if local time is dependent on the users clock, and can be wrong, then
any other time would inherently be wrong?

I think what the OP wanted was some way to show what time it is, based on an
accurate time source, irregardless of the users time settings.
--
Randy
Jul 20 '05 #5

P: n/a
JRS: In article <20***************************@mb-m25.aol.com>, seen in
news:comp.lang.javascript, HikksNotAtHome <hi************@aol.com>
posted at Thu, 18 Dec 2003 23:47:39 :-
In article <Eo**************@merlyn.demon.co.uk>, Dr John Stockton
<sp**@merlyn.demon.co.uk> writes:

<--snip-->
It would be of great value if the time of some central source could be
drawn, in the form of a ".js" file, into the script to avoid
dependence on the client's date/time.

The returned date/time needs to be GMT. For us, the best form would be
as a value of milliseconds since 1970-01-01 00:00:00 GMT, which can be
directly applied : var T = new Date(Number) or new Date(+String) .


Doesn't all of it still depend on the clients clock being set correctly?
Meaning, if local time is dependent on the users clock, and can be wrong, then
any other time would inherently be wrong?

I think what the OP wanted was some way to show what time it is, based on an
accurate time source, irregardless of the users time settings.

If one can import a current value for milliseconds since 1970-01-01
00:00:00 GMT, one can use it in at least two ways.

One can check that new Date() gives the same within some reasonable
tolerance, allowing for time taken to do the importing, and if they
differ by more than, say, 15000, do alert("I say, could your clock be
wrong?").

Or one can note the difference, and add it to the result of any
subsequent new Date() operation.
One can then show GMT as-it-is (relying on user's clock rate); a page
cannot show user's local time without relying on the user's zone
settings.

Since at a given instant there can be no more than 25 (hourly zones
-12..+12) + about 2 (zones wrong side of Line) + about 10 (fractional
hour offsets) correct readings for a local-time clock, a Web page
could however show them all. Just load the strings into the box of
<URL:http://www.merlyn.demon.co.uk/js-date5.htm#SLHGD>.
AIUI, under standard conditions, a Web page (using HTML, javascript and
no more) obtained from domain A cannot read explicit data from arbitrary
domain B - e.g. as author I can frame or pop-up (?) a page of yours, but
I cannot read its words. I could, however, ask the reader to
copy'n'paste the date/time string off your page into my input control.

How, then, can such a page transfer a number from a co-operating alien
domain into a javascript variable? For time, to the second, one needs
32 bits; 8 Hex characters.

ISTM that script may be able to determine the size of an alien graphic?
If so, load 4 alien GIFs showing blankness, each of whose height and
width together encode 2 hex digits - max size only 15/16 square - and
decode.

Or make 32 requests http://X.Y.Z?n for n = 0..31, with only those for
which the current time has a 1 bit giving a response??

To avoid rollover uncertainty, gray-code the underlying 32 bits, which
also Grey-codes the Hex.

All untested.

--
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 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.