php_nub_qq Posted October 27, 2013 Share Posted October 27, 2013 Basically my website is worldwide and I need to be able to detect users' time zones and display accurate times. I have this really neat script which used to work flawlessly well until now. It needs a timezone offset which I fetch with javascript and pass through a cookie. if(!empty($_COOKIE['tz']) && $_COOKIE['tz']>=-12 && $_COOKIE['tz']<=13){ $offset = $_COOKIE['tz']; $tz = timezone_name_from_abbr(null, $offset * 3600, true); if($tz === false) $tz = timezone_name_from_abbr(null, $offset * 3600, false); date_default_timezone_set($tz); }else{ date_default_timezone_set('UTC'); } The problem is that currently the timezone I'm testing in is Europe/Helsinki, which is UTC+2 (without daylight savings), but for some reason timezone_name_from_abbr() decides 2*3600 is Europe/Paris. I'm really bad with dates and time zones, I desperately need help, please! Quote Link to comment https://forums.phpfreaks.com/topic/283350-timezone_name_from_abbr-not-recognizing-correctly/ Share on other sites More sharing options...
Barand Posted October 28, 2013 Share Posted October 28, 2013 With daylight savings param = true, offset and timezones are 1 : Europe/London 2 : Europe/Paris 3 : Europe/Helsinki 4 : Europe/Moscow With the dst parameter = false 1 : Europe/Paris 2 : Europe/Helsinki 3 : Europe/Moscow 4 : Asia/Dubai Quote Link to comment https://forums.phpfreaks.com/topic/283350-timezone_name_from_abbr-not-recognizing-correctly/#findComment-1455869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.