summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/helpers/date_helper.php29
-rw-r--r--system/libraries/Session.php14
2 files changed, 25 insertions, 18 deletions
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index c601dc9e5..a5c46e47b 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -42,29 +42,28 @@ if ( ! function_exists('now'))
/**
* Get "now" time
*
- * Returns time() or its GMT equivalent based on the config file preference
+ * Returns time() based on the timezone parameter or on the
+ * "time_reference" setting
*
+ * @param string
* @return int
*/
- function now()
+ function now($timezone = NULL)
{
- $CI =& get_instance();
-
- if (strtolower($CI->config->item('time_reference')) === 'gmt')
+ if (empty($timezone))
{
- $now = time();
- $system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
-
- 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 = config_item('time_reference');
+ }
- return $system_time;
+ if ($timezone === 'local' OR $timezone === date_default_timezone_get())
+ {
+ return time();
}
- 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/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);
}
// --------------------------------------------------------------------