Below is a quote form https://bitbucket.org/pellepim/jstimezonedetect/wiki/Home:
To simply store away a user’s timezone in a variable, you can simply import timezone_detect.js and do the following.
var timezone = determine_timezone().timezone; // Now you have an instance of the TimeZone object. alert(timezone.utc_offset); // Offset in minutes from UTC alert(timezone.olson_tz); // Olson database timezone key (ex: Europe/Amsterdam) alert(timezone.uses_dst); // bool for whether the tz uses daylight saving time
This gives you an Olson database key you can use for datetime calculations in most programming languages.
After declaring the
timezone.olson_tz is already in a php friendly format, we can then directly save it in a cookie with
setCookie("timezone_js", timezone.olson_tz, 365).
When the data is stored in a cookie, the php script can start to take over. we can call the cookie by simply calling the
$_COOKIE["timezone_js"] and putting it in
date_default_timezone_set($_COOKIE["timezone_js"] ). That way, your web is now in the same timezone as the client.
That’s all from me, happy blogging!