Re: displaying time on the server

From: Date: Wed, 15 Oct 2003 21:24:25 +0000
Subject: Re: displaying time on the server
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-166257@lists.php.net to get a copy of this message
From: "Adam Williams" <awilliam@mdah.state.ms.us> > 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...

« previous php.general (#166257) next »