summaryrefslogtreecommitdiffstats
path: root/system/helpers/date_helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers/date_helper.php')
-rw-r--r--system/helpers/date_helper.php28
1 files changed, 13 insertions, 15 deletions
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index c601dc9e5..3b0c3289d 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -42,29 +42,27 @@ 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 "timezone"
+ * setting
*
+ * @param string
* @return int
*/
- function now()
+ function now($timezone = NULL)
{
- $CI =& get_instance();
+ $CI =& get_instance();
- if (strtolower($CI->config->item('time_reference')) === 'gmt')
+ if (is_null($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.');
- }
-
- return $system_time;
+ $timezone = $CI->config->item('timezone');
}
- return time();
+ $timezone = new DateTimeZone($timezone);
+ $now = new DateTime('now', $timezone);
+ $offset = $timezone->getOffset($now);
+ $time = time() + $offset;
+
+ return $time;
}
}