server time/date

R

Ron Croonenberg

Hello,

does anyone know of a simple script to get the date and time on the
server an html document is served from ? (or a simple script to read an
html doc that only has one line in the body section ?)

thanks,

Ron
 
R

Ron Croonenberg

Hi Randy,

I did that, but problem with that is that you don't know for how long a
page has been "sitting" there before a user does something.
(for all that I know he/she could load a page.. and go out to lunch)
 
E

Evertjan.

Ron Croonenberg wrote on 29 nov 2007 in comp.lang.javascript:
does anyone know

This Q should really only be answered with: Yes!
of a simple script to get the date and time on the
server an html document is served from ?

Still, let me give an answer:

With ASP-jscript you can do:

<script language='jscript' runat='server'>
response.write(new Date());
(or a simple script to read an
html doc that only has one line in the body section ?)

What is an "html doc"?

Why one line? Is this a school assignment?
 
R

Ron Croonenberg

With ASP-jscript you can do:

ASP ? that's a windows thing... right ?
<script language='jscript' runat='server'>
response.write(new Date());


What is an "html doc"?

those things that you can find in the document root of for example an
apache server ?
Why one line? Is this a school assignment?

Uhm no... but I can have a php script report the time, so if I can
request a "html doc" than i can read that script's output and get the
time that way.
 
R

Ron Croonenberg

Hi Randy,

thanks, I really appreciate it.

Randy said:
Ron Croonenberg said the following on 11/29/2007 3:10 AM:

Uhm no... but I can have a php script report the time, so if I can
request a "html doc" than i can read that script's output and get the
time that way.

function loadJSFile(fileURL){
if (document &&
document.createElement &&
document.appendChild &&
document.getElementsByTagName)
{
var newScript = document.createElement('script');
newScript.type = "text/javascript";
newScript.src = fileURL;
document.getElementsByTagName('head')[0].appendChild(newScript);
}
}

loadJSFile('getTimeOnTheServer.php')

And then have getTimeOnTheServer.php return the time, along with a
function call to do something with the time. Instead of having PHP just
return a one line file with the time, it would look something like this:

var serverTime = <?php echo time() ?>;
someFunctionInThePageToDoSomethingWithTheTimeVariable();
 
E

Evertjan.

Ron Croonenberg wrote on 29 nov 2007 in comp.lang.javascript:
ASP ? that's a windows thing... right ?

ASP allows serverside j[ava]script
those things that you can find in the document root of for example an
apache server ?

I wouldn't know, I asked you.
Uhm no... but I can have a php script report the time, so if I can
request a "html doc" than i can read that script's output and get the
time that way.

php is off topic on this NG. Please aske in a php NG.

And why one line?
 
D

Dr J R Stockton

Wed said:
does anyone know of a simple script to get the date and time on the
server an html document is served from ? (or a simple script to read an
html doc that only has one line in the body section ?)

In my experience, ordinary servers cannot be trusted to get the date and
time right to within a reasonable accuracy.

Use instead a site which has a special interest in displaying date and
time.

A server should of course give the UTC date and time. Server local date
and time do not necessarily match either that of the end user or that of
the owner of the site - particularly in the larger countries.
 
R

Ron Croonenberg

Dr said:
In my experience, ordinary servers cannot be trusted to get the date and
time right to within a reasonable accuracy.

Oh, the ones I use can be trusted, they run all run ntp and are sync-ed
with a stratum 0 server.
Use instead a site which has a special interest in displaying date and
time.

uhm, ok.. but I was more interested in time differences anyway..
A server should of course give the UTC date and time. Server local date
and time do not necessarily match either that of the end user or that of
the owner of the site - particularly in the larger countries.

correct, but I am pretty sure that the servers I work with are pretty
accurate.

Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,147
Messages
2,570,835
Members
47,382
Latest member
MichaleStr

Latest Threads

Top