Advertisement
tribulant

Untitled

Feb 28th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. function set_timezone() {
  2.             $timezone_format = _x('Y-m-d G:i:s', 'timezone date format');
  3.             $current_offset = get_option('gmt_offset');
  4.             $tzstring = get_option('timezone_string');
  5.             $check_zone_info = true;
  6.             if (false !== strpos($tzstring,'Etc/GMT')) { $tzstring = ''; }
  7.                    
  8.             if (empty($tzstring)) {
  9.                 $check_zone_info = false;
  10.                 if (0 == $current_offset) {
  11.                     $tzstring = 'UTC+0';
  12.                 } elseif ($current_offset < 0) {
  13.                     $tzstring = 'UTC' . $current_offset;
  14.                 } else {
  15.                     $tzstring = 'UTC+' . $current_offset;
  16.                 }
  17.             }
  18.        
  19.             @putenv("TZ=" . $tzstring);
  20.             @ini_set('date.timezone', $tzstring);
  21.            
  22.             if (function_exists('date_default_timezone_set')) {
  23.                 @date_default_timezone_set($tzstring);
  24.             }
  25.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement