javascript:
<script src="<?= URL::site('/public/js/jstz-1.0.4.min.js'); ?>" type="text/javascript"></script>
<script>
    $(document).ready(function() {  
    var tz = jstz.determine(); // Determines the time zone of the browser client
    });
</script>
php:
<?php 
 $timezone = '<script>
    var tz = jstz.determine(); 
    document.write(tz.name());
</script>';
 ?>
<?php
echo $timezone;
$tz = new DateTimeZone($timezone);//error producing line
$message_date = new DateTime($message_date); 
$message_date->setTimeZone($tz);
$messagedate = $message_date->format('Y-m-d H:i:s');
?>
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 error producing line),i am getting this error "Exception [ 0 ]: DateTimeZone::__construct(): Unknown or bad timezone (<script> var tz = jstz.determine(); document.write(tz.name()); </script>)".
Actually,it is taking the whole $timezone vatiable as string and not variable.Need solution to solve this.
Thanks
 
    