[PHP] displaying time on the server

2003-10-15 Thread Adam Williams
Hello,

I was wondering if someone knew how to display the time on the server to a 
web page that resides on that server, and have it update the time each 
second?  I was looking at javascript for this, but they all use the client 
PC viewing the page to get the time, but I want it to display the server's 
time.  any suggestions on how to do this?  Thanks!

Adam

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] displaying time on the server

2003-10-15 Thread Chris Shiflett
--- Adam Williams [EMAIL PROTECTED] wrote:
 I was wondering if someone knew how to display the time on the
 server to a web page that resides on that server, and have it
 update the time each second?

PHP can't do this. It executes on the server, not on the client.

 I was looking at javascript for this, but they all use the client 
 PC viewing the page to get the time, but I want it to display the
 server's time. any suggestions on how to do this?

You can probably have PHP write your JavaScript and start the clock from the
server's current time. This way, assuming the client's clock doesn't run too
terribly fast or slow, it will be very close to the server's time.

Hope that helps.

Chris

=
My Blog
 http://shiflett.org/
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] displaying time on the server

2003-10-15 Thread CPT John W. Holmes
From: Adam Williams [EMAIL PROTECTED]

 I was wondering if someone knew how to display the time on the server to a
 web page that resides on that server, and have it update the time each
 second?  I was looking at javascript for this, but they all use the client
 PC viewing the page to get the time, but I want it to display the server's
 time.  any suggestions on how to do this?  Thanks!

You'll still need to use Javascript if you want the time actually updating
in the browser. Try to find some js code that'll let you pass a start time
to it. You can then get the server time with PHP and pass it to js. It may
be a few seconds off, depending on the delay of getting the time on the
server and the js actually starting in the browser, but close enough for
govt. work. :)

?
$now = time();
?

script language=javascript
js_now = ?=$now?;
/script

Then use the js_now js variable as a starting point for the clock.

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php