diff options
author | Iban Eguia <admin@razican.com> | 2012-03-27 18:18:15 +0200 |
---|---|---|
committer | Iban Eguia <admin@razican.com> | 2012-03-27 18:18:15 +0200 |
commit | 8310595f0e80f72ac790478b8a7dfc6470051639 (patch) | |
tree | 2639e07bd80bb9a26b5d7e96ead12906dc2b5328 /system/helpers/date_helper.php | |
parent | 67c287192b5ff414753ae50a834932f676a0db9e (diff) |
Changed Date helper to return time() based on the timezone parameter.
Diffstat (limited to 'system/helpers/date_helper.php')
-rw-r--r-- | system/helpers/date_helper.php | 24 |
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; } } |