Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client side time

Status
Not open for further replies.

fluxdemon

MIS
Joined
Nov 5, 2002
Messages
89
Location
US
Is there a way to get the client-side time using PHP? I'm just looking for a simple way the server can query the client system for its local time BEFORE it sends the page.

I haven't found anything on php.net or google.
 
No, there is not away to snatch the client time... unless your PHP page is not the first. Ex:

[tt]-------------index.html------------------
<HTML><BODY>
<H1>What Time Is It?</H1>

<FORM METHOD=&quot;post&quot; ACTION=&quot;whattime.php&quot;>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
var LocalTimeStr;
// ..... some JS magic to determine the time string....
// (I don't know that much JavaScript)
document.write('<input type=hidden name=&quot;time&quot; value=&quot;'+LocalTimeStr+'>');
</SCRIPT>

<INPUT type=submit>
</FORM>
</BODY></HTML>

--------------whattime.php---------------

<HTML><BODY>
<H3>The current local time (according to the client) is <?php echo $_POST['time'] ?>.</H3>
</BODY></HTML>

-------------end-------------------------
[/tt]
I know it's a hack, but it's the only way you might get the time out of the client. I hope you don't need to know the client time on the entry page of your site.

And somebody, please fix my pathetic JavaScript... [lol]

I REALLY hope that helps.
Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top