seidanis Posted June 24, 2006 Share Posted June 24, 2006 Hello,my JS knowledge is close to none, so please bare with me.Finding out the visitor's time zone offset was not that hard:[code]var now = new Date();var tzo = now.getTimezoneOffset();[/code]What I need to do now, is automatically pass "tzo" back to the server, for further processing via PHP. Passing its value onto a PHP variable would be ideal.Any hints please?Alex Quote Link to comment https://forums.phpfreaks.com/topic/12830-local-time/ Share on other sites More sharing options...
.josh Posted June 25, 2006 Share Posted June 25, 2006 well if you are having the user fill out a form you could just pass the var through the form in a hidden field, and retrieve it in php via $_GET['tzo'] or POST['tzo'] (whichever form method you use). or, you could use ajax to send it in the background, and you would still retrieve it in php the same way. Quote Link to comment https://forums.phpfreaks.com/topic/12830-local-time/#findComment-49311 Share on other sites More sharing options...
king arthur Posted June 26, 2006 Share Posted June 26, 2006 There are three basic ways of sending variables to PHP from javascript.You can put them into a cookie which can then be read back by PHP, but only works if the user has cookies enabled.You can put them in a form which the PHP script will get in the $_POST or $_GET array.You can request a script from the server with the variables added as query parameters. This last one could be done in two ways. You either redirect the browser to that script, or you request it as if it were a file such as an image, but instead of trying to load say "dummy.jpg" or "dummy.png" you request "dummy.php?param=whatever". As long as it has query parameters it will not be cached and therefore will be run each time. The script would have to output a dummy image to send back to the browser, but there is nothing to stop it doing other work as long as it doesn't try to generate any HTML. Quote Link to comment https://forums.phpfreaks.com/topic/12830-local-time/#findComment-49582 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.