How to pass browser/javascript based local time to php variable (ajax?)

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How to pass browser/javascript based local time to php variable (ajax?)

hi, i've spent days trying to figure this out and have a similar problem. I've learned html, css, php and others, but ajax baffles me somewhat. Starting to get a hang of it, but all the tutorials I've come across are typically convoluted and not so clear. I'm working on http://001yourtranslationservice.com.../TimeZones.htm
and trying to change the "Your time" at the top (of the alarm clock) based on the user, which requires javascript. I assume the procedure is for js to first determine their local time (probably easiest just from their computer time settings, although I've found some pretty fancy scripts based on internet connection), then to save this little bit of information to an xml file via ajax, then for the js to launch the php script, which will draw the data from the xml file and do its wonders (right now it's php only and the time at the top is based on the server's location, somewhere in the US). The js would be set to refresh the page once a minute. For now the php script is doing that by html page refresh within the iframe. There must be a simpler way to do this then to use jQuery. i'd like to know the basics and not create a monster to do this simple task. Thank you very kindly for your help!

In any case, an XML file shouldn't be required. Javascript/AJAX can pass the user's time and/or timezone offset directly to a PHP page. In fact, AJAX might not be required. Any PHP page which loads into the browser can use javascript to get the user's time.

It might actually be better to use PHP (or any available server side code) to get the server time and use that to find the target time in the client's timezone, then use javascript to calculate the user's time and do the other work to setup the alarm clock.

But if you still want to write an XML file with the user's local time in it, AJAX alone cannot do that. But it can send the data to the server, which can use PHP to write the XML file. But I think the user's minutes difference from UTC might also be helpful, so:

But this is inferior to any real time processing (like the first idea in this post, and others that could be worked out) due to the likelihood that two users might collide over the use of the XML file, unless a unique XML file is generated for each user.