In the navbar.php file that's included on every page on my website, I want to set the timezone for every user. I've found a good js script that works perfectly for me. I can echo the variable and it correctly identifies 'Europe/Brussels' as my timezone. Now I want to be able to set this timezone variable as the timezone in PHP. This is a snippet of the code I currently have in my navbar.php file but it's not working..
<script type="text/javascript" src="domain/js/jstz.js"></script>
<script>
$.ajax({
var tz = jstz.determine();
var tzname = tz.name();
'url': 'navbar.php',
'type': 'POST',
'data': 'timezone=' + tzname
});
</script>
<?php
$usertimezone = $_POST['timezone'];
date_default_timezone_set($usertimezone);
?>
Anyone who can see what's wrong with it and help me? Thanks!