summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/helpers/date_helper.php24
1 files changed, 9 insertions, 15 deletions
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;
}
}