Hi Admin,
I was using the timeFromFormat method and getting a wrong result, So I checked the methods in dates.php (so I am using it wrong or there really is an error in the method)
ex:
input : StartDate & StartTime: string(10) "2016-10-27" & string(
"16:09:00
call to method : $startunix = GuidemanHelperDates::timeFromFormat($data->start_date . ' ' . $data->start_time, '%Y-%m-%d %H:%M:%S');
Result:
In explodeDate() ==> Pos: array(7) { ["minute"]=> bool(false) ["year2"]=> bool(false) ["second"]=> bool(false) ["year4"]=> int(1) ["month"]=> int(4) ["day"]=> int(7) ["hour"]=> int(10) }
array(6) { ["year"]=> string(4) "2016" ["month"]=> string(2) "10" ["day"]=> string(2) "27" ["hour"]=> string(2) "16" ["minute"]=> string(2)
"00" ["second"]=> string(2) "
00" }
When you change the following code in the explodeDate() method:
//Prepare the search depending on attempted format
$pos = array();
$pos = strpos($format, "Y");
$pos = strpos($format, "y");
$pos = strpos($format, "m");
$pos = strpos($format, "d");
$pos = strpos($format, "H");
$pos = strpos($format, "i");
$pos = strpos($format, "s");
to :
//Prepare the search depending on attempted format
$pos = array();
$pos = strpos($format, "Y");
$pos = strpos($format, "y");
$pos = strpos($format, "m");
$pos = strpos($format, "d");
$pos = strpos($format, "H");
$pos = strpos($format, "
M");
$pos = strpos($format, "
S");
it works fine.
Result =
Pos: array(7) { ["year2"]=> bool(false) ["year4"]=> int(1) ["month"]=> int(4) ["day"]=> int(7) ["hour"]=> int(10) ["minute"]=> int(13) ["second"]=> int(16) }
array(6) { ["year"]=> string(4) "2016" ["month"]=> string(2) "10" ["day"]=> string(2) "27" ["hour"]=> string(2) "16" ["minute"]=> string(2) "09" ["second"]=> string(2) "00" }
Kind Regards,
Koen