summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorIban Eguia <admin@razican.com>2012-06-09 23:52:27 +0200
committerIban Eguia <admin@razican.com>2012-06-09 23:52:27 +0200
commite15e3dde9dca15e2d65f098010d3fb7004cef5e7 (patch)
tree26f06c9c26bbb2f54ae37727b6a6e549163f1d93 /system/helpers
parentf5d1fd2ce8bfa049c8049184ac6d385d0f70fe29 (diff)
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()
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/date_helper.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 3b0c3289d..d5acec23f 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -57,10 +57,16 @@ if ( ! function_exists('now'))
$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;
}