Changed Date helper to return time() based on the timezone parameter.
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index f1ba364..aecc7d9 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;
}
}