title: store javascript values in php variable
body: <p>javascript:</p>
  
  <pre><code>&lt;script src="&lt;?= URL::site('/public/js/jstz-1.0.4.min.js'); ?&gt;" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script&gt;
      $(document).ready(function() {  
      var tz = jstz.determine(); // Determines the time zone of the browser client
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>php:</p>
  
  <pre><code>&lt;?php 
   $timezone = '&lt;script&gt;
      var tz = jstz.determine(); 
      document.write(tz.name());
  &lt;/script&gt;';
   ?&gt;
  &lt;?php
  echo $timezone;
  $tz = new DateTimeZone($timezone);//error producing line
  $message_date = new DateTime($message_date); 
  $message_date-&gt;setTimeZone($tz);
  $messagedate = $message_date-&gt;format('Y-m-d H:i:s');
  ?&gt;
  </code></pre>
  
  <p>Above is the javascript to get the timezone.I am getting the timezone via script and assigned that to a php variable.If i echo the php variable (echo $timezone) i am getting the correct timezone.But if i pass the same variable in  timezone conversion code(please see <code>error producing line</code>),i am getting this error "<code>Exception [ 0 ]: DateTimeZone::__construct(): Unknown or bad timezone (&lt;script&gt; var tz = jstz.determine(); document.write(tz.name()); &lt;/script&gt;)</code>".</p>
  
  <p>Actually,it is taking the whole <code>$timezone</code> vatiable as string and not variable.Need solution to solve this.</p>
  
  <p>Thanks</p>