Remember user timezone selection, and apply timezone changes to datetime field on all pages
<p>In my database I have a dateandtime field in one of the tables, which correctly displays the date and time from the database for the row I want. As I will possibly get users from many different countries I will need to allow a user to select their timezone so that the time in the time and date in the dateandtime field will be changed to their timezone across all pages of my site.</p>

<p>I am able to successfully allow the user to type in a input field the time zone such as "+3:00" and enter a date such as "24/07/2017" into another input field, and when the user clicks the Search button the timezone conversion will be successful. This is not ideal though as it means everytime the user goes to another page on the site and goes back to the search by date page they have to input the timezone e.g. "+3:00" again.</p>

<p>I was thinking that a session could be used to achieve what I need but when I tried using a session to remember the timezone value when I went back to the page the time would no longer be in the timezone I had previously inputted.</p>

<p>To summarise, what I am trying to achieve is that I would like the user to be able to select their timezone and for any dates and times displayed on the webpages from the database will be changed to the users selected timezone, and if the user was to go off the page then their timezone will be remembered if they were to go back to the previous page.</p>

<p>An example site that shows what I am trying to achieve successfully is below</p>

<p><a href="http://liveonsat.com/los_soc_int_UEFA_CL.php" rel="nofollow">A site which has the functionality with timezones I am attempting to achieve</a></p>

<p>As you can see on that site if I select timezone, it successfully changes the timezone, and if I was to select another section of the site it would remember the users timezone and update the date and time to reflect the timezone changes. It seems after inspection that that site uses a cookie to remember the timezone value, would I be able to use cookies to achieve this type of functionality on my site?</p>

<p>Below is the code I have that successfully changes the timezone when the user inputs a timezone value e.g. "+3:00" and date into the corresponding input fields but will not remember timezone option.</p>

<pre><code>&lt;?php
include './config.php';
include './header.php';





$timezone = trim($_GET["timezone"]);
$keyword = trim($_GET["keyword"]);
if ($keyword &lt;&gt; "" &amp;&amp; $timezone &lt;&gt; "" ) {
$sql = "SELECT f.hometeam, f.awayteam, f.sport, f.competition,
DATE_FORMAT(CONVERT_TZ(f.dateandtime, '+00:00','$timezone'), '%M %e, %Y %r') AS dateandtime,
Group_concat(s.name SEPARATOR ',') name,
Group_concat(x.channelid_fc SEPARATOR ',') channelid_fc
FROM footballfixtures f
LEFT JOIN fixturechannels x
ON x.matchid_fc=f.matchid
LEFT JOIN satellite s
ON x.channelid_fc=s.channelid
WHERE DATE(dateandtime) = STR_TO_DATE('$keyword', '%d/%m/%Y')
GROUP BY f.hometeam, f.awayteam, f.sport, f.competition, f.dateandtime
ORDER BY f.dateandtime ";

$stmt = $DB-&gt;prepare($sql);

$stmt-&gt;bindValue(":keyword", $keyword."%");
$stmt-&gt;bindValue(":timezone", $timezone." %");


$stmt-&gt;execute();

} else {


$sql = "SELECT 1 from dual";

$stmt = $DB-&gt;prepare($sql);
}

$stmt-&gt;execute();





?&gt;
&lt;html&gt;

&lt;head&gt;






&lt;/head&gt;

&lt;body&gt;

&lt;div class="container mainbody"&gt;
&lt;div class="mainpagetitle"&gt;
&lt;h11&gt;Sports Schedule&lt;/h11&gt; &lt;br&gt; &lt;br&gt;
&lt;p&gt;We aim to provide you with sports schedule in an easy to view  format&lt;/p&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt;
&lt;form class="form-inline"&gt;
&lt;/div&gt;


&lt;div class="clearfix"&gt;&lt;/div&gt;

&lt;div class="col-xs-12"&gt;
      &lt;img src="css/calendar.png" class="img-responsive" /&gt;

               &lt;div id=class="container-fluid"&gt;
&lt;div class="row"&gt;
  &lt;h2&gt;Search by Date&lt;/h2&gt; &lt;br&gt;
&lt;p&gt; Please Enter Date &lt;/p&gt;

&lt;/div&gt;  
&lt;/div&gt;
&lt;/div&gt;


&lt;div class="searchform"&gt;
    &lt;form action="bydate.php" method="get" &gt;
        &lt;label class="col-xs-12" for="timezone";&gt;
          &lt;select name="timezone" id="timezone"&gt;
&lt;option value="+1:00"&gt;+1:00&lt;/option&gt;
&lt;option value="+2:00"&gt;+2:00&lt;/option&gt;
&lt;option value="+3:00"&gt;+3:00&lt;/option&gt;
&lt;option value="+4:00"&gt;+4:00&lt;/option&gt;
&lt;/select&gt;

        &lt;/label&gt;






  &lt;div class="searchform"&gt;
    &lt;form action="bydate.php" method="get" &gt;
        &lt;label class="col-xs-12" for="keyword";&gt;
          &lt;input type="text" value="&lt;?php echo htmlspecialchars($_GET["keyword"]); ?&gt;" placeholder="Enter Team Name" id="" class="form-control" name="keyword"&gt;

        &lt;/label&gt;



      &lt;button class="btn btn-info"&gt;search&lt;/button&gt;
    &lt;/form&gt;
    &lt;/div&gt;
    &lt;/div&gt;




  &lt;div class="clearfix"&gt;&lt;/div&gt;


 &lt;div class="container"&gt;
 &lt;div class="row"&gt;
 &lt;div class="tables"&gt;
 &lt;div class="col-xs-12"&gt;


 &lt;table class="table table-hover footable"&gt;
 &lt;thead&gt;
 &lt;tr&gt;
            &lt;th&gt;Home Team&lt;/th&gt;
              &lt;th&gt; vs &lt;/th&gt;
            &lt;th&gt;Away Team&lt;/th&gt;
            &lt;th data-hide="phone, tablet"&gt;Sport&lt;/th&gt;
            &lt;th data-hide="phone, tablet"&gt;Competition&lt;/th&gt;
            &lt;th data-hide="phone, tablet"&gt;Date and Time&lt;/th&gt;
            &lt;th data-hide="phone, tablet"&gt;Channels&lt;/th&gt;  
            &lt;/tr&gt;
          &lt;/thead&gt;

  &lt;?php         

  if($stmt-&gt;rowCount() &gt;0) {   

       while ($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC))
  {


     $hometeam = $row['hometeam'];
     $versus= $row['versus'];
         $awayteam= $row['awayteam'];
         $sport= $row['sport'];
         $competition = $row['competition'];
         $dateandtime=$row['dateandtime'];
         $name=explode(',', $row['name']);
         $channelid=explode(',', $row['channelid_fc']);

    ?&gt;
    &lt;tbody&gt;

  &lt;tr&gt;
  &lt;td&gt; &lt;?php echo $row[hometeam] ; ?&gt; &lt;/td&gt;
  &lt;td&gt; &lt;?php echo $row[versus] ; ?&gt; &lt;/td&gt;
 &lt;td&gt; &lt;?php echo $row[awayteam] ; ?&gt; &lt;/td&gt;
 &lt;td&gt; &lt;?php echo $row[sport] ; ?&gt; &lt;/td&gt;
 &lt;td&gt; &lt;?php echo $row[competition] ; ?&gt; &lt;/td&gt;
  &lt;td&gt; &lt;?php echo $row[dateandtime] ; ?&gt; &lt;/td&gt;

&lt;td&gt;
&lt;?php for ($i = 0; $i &lt; count($channelid) &amp;&amp; $i &lt; count($name); ++$i) {
$achannelid = $channelid[$i];
$aname = $name[$i];


        echo "&lt;a href='http://sportschedule.xyz/view_channels.php?channelid=" .$achannelid."'&gt; ".$aname." &lt;/br&gt; &lt;/a&gt; ";

        }

        ?&gt;

  &lt;/tbody&gt;       
&lt;/td&gt;
 &lt;/tr&gt;
&lt;?php  } ?&gt;
&lt;?php } else { ?&gt;
&lt;p&gt;No matches found for the team you searched. Please try again&lt;/p&gt;
 &lt;?php } ?&gt;
&lt;/table&gt;   

   &lt;/div&gt;
   &lt;/div&gt;
   &lt;/div&gt;
   &lt;/div&gt;

   &lt;script&gt;

   $('.footable').footable({ addRowToggle: false });


      $('.footable').footable({
  calculateWidthOverride: function() {
    return { width: $(window).width() };
  }
}); 

    $(document).ready(function(){ if ($.trim($(".footable tbody").text()).length == 0) { $('.footable').hide(); } });  

&lt;/script&gt;


      &lt;/body&gt;
      &lt;/html&gt;    
</code></pre>

<p>Many Thanks to anyone who reads, and/or suggests how I could achieve a solution or steers me in the right direction for assistance</p>