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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP: Client time without entering GMT!

Status
Not open for further replies.

sbs

Programmer
Jun 27, 2000
1
0
0
DK
<br>At the moment I'm building a website, and I need the date and time FROM THE CLIENT maschine. I can't figure out how to gather the information needed, without asking the user to supply the timezone, in which they live.<br><br>Currently I haven't heard about any kind of solution to this problem, so I would be extraordinary happy if one of you guys have a solution.
 
I am sorry, but PHP will only return the time relative to the server unless you perform this kind of trick to create a custom time value:<br><br>getdate(timestamp); <br><br>Javascript can be used to return the timestamp value which will of course return the value for local time instead of time relative to the server.<br><br>Thus, using the following should work just fine:<br><br>My computer tells me that it is July 4th, 2000 at 11:33am so the timestamp value is 962732315 (you must get this using Javascript, not PHP.<br><br>&lt;?php<br>$local_time = getdate(&quot;962732315&quot;);<br><br>$hour = $local_time[&quot;hours&quot;];<br>$minute = $local_time[&quot;minutes&quot;];<br>$second = $local_time[&quot;seconds&quot;];<br>$day = $local_time[&quot;mday&quot;];<br>$month = $local_time[&quot;month&quot;];<br><br>//and so on....<br>?&gt;<br><br>Sincerely,<br>Chad.
 
<br>and how do you get the timestamp from JS?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top