summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIban Eguia <admin@razican.com>2012-06-12 16:09:36 +0200
committerIban Eguia <admin@razican.com>2012-06-12 16:09:36 +0200
commitfeb14dac4e7a417a48344a5188a8ad8074871df4 (patch)
treeecbd2962417cdb7b38c0332908acb96784870891
parentc88daba688d309150a7dce43817ab76ec7834bda (diff)
Changed the config parameter. The session's _get_time() function has also changed.
-rw-r--r--application/config/config.php4
-rw-r--r--system/helpers/date_helper.php2
-rw-r--r--system/libraries/Session.php14
-rw-r--r--user_guide_src/source/helpers/date_helper.rst6
-rw-r--r--user_guide_src/source/installation/upgrade_300.rst5
5 files changed, 18 insertions, 13 deletions
diff --git a/application/config/config.php b/application/config/config.php
index 12ef77c76..fd6a1aeb0 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -359,7 +359,7 @@ $config['compress_output'] = FALSE;
/*
|--------------------------------------------------------------------------
-| Master Timezone
+| Master Time Reference
|--------------------------------------------------------------------------
|
| You can set any PHP supported timezones to be the master timezone when
@@ -367,7 +367,7 @@ $config['compress_output'] = FALSE;
| time.
|
*/
-$config['timezone'] = 'local';
+$config['time_reference'] = 'local';
/*
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index b818da9d8..131508f69 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -52,7 +52,7 @@ if ( ! function_exists('now'))
{
if (empty($timezone))
{
- $timezone = config_item('timezone');
+ $timezone = config_item('time_reference');
}
if ($timezone === 'local' OR $timezone === date_default_timezone_get())
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 7beedd96b..9fdf744c3 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -786,9 +786,17 @@ class CI_Session {
*/
protected function _get_time()
{
- return (strtolower($this->time_reference) === 'gmt')
- ? mktime(gmdate('H'), gmdate('i'), gmdate('s'), gmdate('m'), gmdate('d'), gmdate('Y'))
- : time();
+ $timezone = config_item('time_reference');
+
+ if ($timezone === 'local' OR $timezone === date_default_timezone_get())
+ {
+ return time();
+ }
+
+ $datetime = new DateTime('now', new DateTimeZone($timezone));
+ sscanf($datetime->format('j-n-Y G:i:s'), '%d-%d-%d %d:%d:%d', $day, $month, $year, $hour, $minute, $second);
+
+ return mktime($hour, $minute, $second, $month, $day, $year);
}
// --------------------------------------------------------------------
diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst
index 33b39bd5b..7bbfd4f15 100644
--- a/user_guide_src/source/helpers/date_helper.rst
+++ b/user_guide_src/source/helpers/date_helper.rst
@@ -30,11 +30,9 @@ it will return time().
:returns: integer
::
+ echo now("Australia/Victoria");
- $tz = "Australia/Victoria";
- echo now($tz);
-
-If a timezone is not provided, it will return time() based on "timezone" setting.
+If a timezone is not provided, it will return time() based on "time_reference" setting.
mdate()
=======
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index c2c3899ee..debf9662c 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -45,9 +45,8 @@ need to rename the `$active_record` variable to `$query_builder`.
Step 5: Change your use of the Date helper's now() function
===========================================================
-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: `Supported timezones <http://www.php.net/timezones>`_. You can also
+Function now() has been modified. You can see the changes in :doc:`Date Helper <../helpers/date_helper>`.
+You can now select all PHP supported timezones in the `time_reference` setting, 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