tags:

views:

1239

answers:

2
+4  Q: 

UTC Offset in PHP

What's the easiest way to get the UTC offset in PHP, relative to the current (system) timezone?

+1  A: 

timezone_offset_get()

$this_tz_str = date_default_timezone_get();
$this_tz = new DateTimeZone($this_tz_str);
$now = new DateTime("now", $this_tz);
$offset = $this_tz->getOffset($now);

Untested, but should work

John Millikin
Useful if you're using the DateTime class in PHP 5. But I'm not.
Adam Ernst
+7  A: 
  date('Z');

returns the UTC offset in seconds.

Czimi