Not changing the time zone maybe best but the only way as it seems is 
the following:

function getNonDstOffset($timeZone, $dateTime)
{
  $env_tz = date_default_timezone_get();
  date_default_timezone_set($timeZone->getName());
  $localtime = localtime(time(), true);
  date_default_timezone_set($env_tz);
 
  $offset = timezone_offset_get($timeZone, $dateTime);
  $offset = $offset / (60 * 60) - (($localtime['tm_isdst'])?1:0); 
//converts to hours
 
  return $offset;
}

Also what side effects can the change of default time zone and turning 
it back almost immediately have?

Regards,
Kupo

Dan Grossman wrote:
> This isn't Symfony specific, but thought one of ya PHP gurus might be 
> able to help.
>
> I have some time zone strings (ex: "America/New_York" or 
> "Europe/London"), and want to find the GMT offset of that timezone, 
> *without DST adjustments*. In other words, the offset (like GMT -5) that 
> I print should be consistent throughout the year.
>
> The first part I've figured out; how to easily remove DST adjustments I 
> haven't. For example, for Europe/London, I get GMT+1 right now, where I 
> want GMT+0, as it will be during London's winter.
>
>         $dateTimeZone = new DateTimeZone($timeZoneString);
>         $dateTime = new DateTime("now", $dateTimeZone);
>         $offset = $dateTimeZone->getOffset($dateTime);
>         if ($offset != 0) {
>             $offset = $offset / (60 * 60); //converts to hours
>         }
>
> Switching the timezone setting with date_default_timezone_set() or 
> putenv('TZ=') can have side-effects, so something that doesn't involve 
> tricking the thread into thinking it's in a different timezone would be 
> best.
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to