summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIban Eguia <admin@razican.com>2012-03-27 18:18:15 +0200
committerIban Eguia <admin@razican.com>2012-03-27 18:18:15 +0200
commit8310595f0e80f72ac790478b8a7dfc6470051639 (patch)
tree2639e07bd80bb9a26b5d7e96ead12906dc2b5328
parent67c287192b5ff414753ae50a834932f676a0db9e (diff)
Changed Date helper to return time() based on the timezone parameter.
-rw-r--r--application/config/config.php16
-rw-r--r--index.php2
-rw-r--r--system/helpers/date_helper.php24
3 files changed, 18 insertions, 24 deletions
diff --git a/application/config/config.php b/application/config/config.php
index 2628885f0..4d0e5080a 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -204,7 +204,7 @@ $config['directory_trigger'] = 'd'; // experimental not currently in use
| 4 = All Messages
|
| You can also pass in a array with threshold levels to show individual error types
-|
+|
| array(2) = Debug Messages, without Error Messages
|
| For a live site you'll usually only enable Errors (1) to be logged otherwise
@@ -253,7 +253,7 @@ $config['cache_path'] = '';
|
| If you use the Encryption class or the Session class you
| MUST set an encryption key. See the user guide for info.
-|
+|
| http://codeigniter.com/user_guide/libraries/encryption.html
| http://codeigniter.com/user_guide/libraries/sessions.html
|
@@ -297,7 +297,7 @@ $config['sess_time_to_update'] = 300;
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
| 'cookie_path' = Typically will be a forward slash
| 'cookie_secure' = Cookies will only be set if a secure HTTPS connection exists.
-| 'cookie_httponly' = Cookie will only be accessible via HTTP(S) (no javascript)
+| 'cookie_httponly' = Cookie will only be accessible via HTTP(S) (no javascript)
|
*/
$config['cookie_prefix'] = "";
@@ -359,16 +359,14 @@ $config['compress_output'] = FALSE;
/*
|--------------------------------------------------------------------------
-| Master Time Reference
+| Master Timezone
|--------------------------------------------------------------------------
|
-| Options are 'local' or 'gmt'. This pref tells the system whether to use
-| your server's local time as the master 'now' reference, or convert it to
-| GMT. See the 'date helper' page of the user guide for information
-| regarding date handling.
+| You can set any PHP supported timezones to be the master timezone when
+| you call th now() function.
|
*/
-$config['time_reference'] = 'local';
+$config['timezone'] = 'UTC';
/*
diff --git a/index.php b/index.php
index 5a1190112..28586093d 100644
--- a/index.php
+++ b/index.php
@@ -162,6 +162,8 @@ if (defined('ENVIRONMENT'))
// 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 f1ba364f5..aecc7d90f 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -46,25 +46,19 @@
*/
if ( ! function_exists('now'))
{
- function now()
+ function now($timezone = NULL)
{
- $CI =& get_instance();
+ $CI =& get_instance();
- if (strtolower($CI->config->item('time_reference')) == 'gmt')
- {
- $now = time();
- $system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
+ if (is_null($timezone))
+ $timezone = $CI->config->item('timezone');
- if (strlen($system_time) < 10)
- {
- $system_time = time();
- log_message('error', 'The Date class could not set a proper GMT timestamp so the local time() value was used.');
- }
+ $timezone = new DateTimeZone($timezone);
+ $now = new DateTime('now', $timezone);
+ $offset = $timezone->getOffset($now);
+ $time = time() + $offset;
- return $system_time;
- }
-
- return time();
+ return $time;
}
}