Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I wrote a function using jQuery and PHP. This is tested, and does work!</p> <p>On the PHP page where you are want to have the timezone as a variable, have this snippet of code somewhere near the top of the page:</p> <pre><code>&lt;?php session_start(); $timezone = $_SESSION['time']; ?&gt; </code></pre> <p>This will read the session variable "time", which we are now about to create.</p> <p>On the same page, in the , you need to first of all include jQuery:</p> <pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt; </code></pre> <p>Also in the , below the jQuery, paste this:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { if("&lt;?php echo $timezone; ?&gt;".length==0){ var visitortime = new Date(); var visitortimezone = "GMT " + -visitortime.getTimezoneOffset()/60; $.ajax({ type: "GET", url: "http://domain.com/timezone.php", data: 'time='+ visitortimezone, success: function(){ location.reload(); } }); } }); &lt;/script&gt; </code></pre> <p>You may or may not have noticed, but you need to change the url to your actual domain.</p> <p>One last thing. You are probably wondering what the heck timezone.php is. Well, it is simply this: (create a new file called <strong>timezone.php</strong> and point to it with the above url)</p> <pre><code>&lt;?php session_start(); $_SESSION['time'] = $_GET['time']; ?&gt; </code></pre> <p>If this works correctly, it will first load the page, execute the JavaScript, and reload the page. You will then be able to read the $timezone variable and use it to your pleasure! It returns the current UTC/GMT time zone offset (GMT -7) or whatever timezone you are in. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload