Fixed timezone change in index.php
Now it does not ever change the local timezone, and it adds the option to get the 'local' time()
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 3b0c328..d5acec2 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -57,10 +57,16 @@
$timezone = $CI->config->item('timezone');
}
- $timezone = new DateTimeZone($timezone);
- $now = new DateTime('now', $timezone);
- $offset = $timezone->getOffset($now);
- $time = time() + $offset;
+ $time = time();
+ if(strtolower($timezone) != 'local')
+ {
+ $local = new DateTime(NULL, new DateTimeZone(date_default_timezone_get()));
+ $now = new DateTime(NULL, new DateTimeZone($timezone));
+ $lcl_offset = $local->getOffset();
+ $tz_offset = $now->getOffset();
+ $offset = $tz_offset - $lcl_offset;
+ $time = $time + $offset;
+ }
return $time;
}