diff options
author | Jonathon Hill <jhill@brandmovers.com> | 2012-11-12 14:51:41 +0100 |
---|---|---|
committer | Jonathon Hill <jhill@brandmovers.com> | 2012-11-12 14:51:41 +0100 |
commit | 3978fc33d82dd7f778d1adbf30744f4dfac41c25 (patch) | |
tree | f32be1ae610f0cfeff65c35abecd14e8ea5cadc6 /system/helpers/date_helper.php | |
parent | 275cf274860c6ed181d50b398efd3a21d7ba9135 (diff) | |
parent | a9ab46d7a031bda304eb9b6658ffaf693b8d9bcb (diff) |
Merge remote-tracking branch 'upstream/develop' into develop
Conflicts:
user_guide_src/source/changelog.rst
Signed-off-by: Jonathon Hill <jhill@brandmovers.com>
Diffstat (limited to 'system/helpers/date_helper.php')
-rw-r--r-- | system/helpers/date_helper.php | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 5d9251526..0fa400d7e 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -1,4 +1,4 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php /** * CodeIgniter * @@ -24,6 +24,7 @@ * @since Version 1.0 * @filesource */ +defined('BASEPATH') OR exit('No direct script access allowed'); /** * CodeIgniter Date Helpers @@ -449,20 +450,13 @@ if ( ! function_exists('human_to_unix')) return FALSE; } - $split = explode(' ', $datestr); + sscanf($datestr, '%d-%d-%d %s %s', $year, $month, $day, $time, $ampm); + sscanf($time, '%d:%d:%d', $hour, $min, $sec); + isset($sec) OR $sec = 0; - list($year, $month, $day) = explode('-', $split[0]); - - $ex = explode(':', $split['1']); - - $hour = (int) $ex[0]; - $min = (int) $ex[1]; - $sec = ( ! empty($ex[2]) && preg_match('/[0-9]{1,2}/', $ex[2])) - ? (int) $ex[2] : 0; - - if (isset($split[2])) + if (isset($ampm)) { - $ampm = strtolower($split[2]); + $ampm = strtolower($ampm); if ($ampm[0] === 'p' && $hour < 12) { |