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/index.php b/index.php
index 62fc2ab..3b00dd3 100644
--- a/index.php
+++ b/index.php
@@ -162,8 +162,6 @@
// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
// --------------------------------------------------------------------
-date_default_timezone_set('UTC');
-
/*
* ---------------------------------------------------------------
* Resolve the system path for increased reliability
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;
}
diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst
index b6c6ed4..33b39bd 100644
--- a/user_guide_src/source/helpers/date_helper.rst
+++ b/user_guide_src/source/helpers/date_helper.rst
@@ -21,7 +21,8 @@
=====
Returns the current time as a Unix timestamp, based on the "timezone" parameter.
-All PHP available timezones are supported.
+All PHP available timezones are supported. You can also use 'local' timezone, and
+it will return time().
.. php:method:: now($timezone = NULL)
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index e86ef67..c2c3899 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -47,7 +47,8 @@
Function now() has been modified. You can see the changes in :doc:`Date Helper <../helpers/date_helper>`
You must replace $config['time_reference'] with $config['timezone'] in your config.php file. You can select all
-PHP supported timezones, listed here: `PHP's supported timezones <http://www.php.net/timezones>`_.
+PHP supported timezones, listed here: `Supported timezones <http://www.php.net/timezones>`_. You can also
+use 'local' if you want to get time().
Step 6: Move your errors folder
===============================