$hours = array();
$heures = Configuration::renvoyer_heures_debut_fin();
$arr_heures = explode('#',$heures->heures_debut_fin);
$start = new \DateTime($arr_heures[0].':00');
$end = clone $start;
$end->setTime($arr_heures[1], 0);
If value of $end is 17:45, I obtain each time 17:00
print_r of $start (true value = 13:30) and $end (true value = 17:45) :
DateTime Object ( [date] => 2013-08-12 13:30:00 [timezone_type] => 3 [timezone] => Europe/Berlin ) DateTime Object ( [date] => 2013-08-12 17:00:00 [timezone_type] => 3 [timezone] => Europe/Berlin )
The second DateTime should be 17:45 and not 17:00
print_r of $arr_heures is :
Array ( [0] => 13:30 [1] => 17:45 )
The PHP log shows me this error :
A non well formed numeric value encountered in /Applications/MAMP/htdocs/imaginatiff/reservations/PHP/class/Calendrier.class.php on line 64
Line 64 is $end->setTime($arr_heures[1], 0);
Have you got an idea please ? Thank you.
You are using setTime
incorrectly -- the hour and minute should be separate parameters.
Correct would be:
list ($h, $m) = explode(':', $arr_heures[1]);
$end->setTime($h, $m); // you can omit seconds when zero
Reading the manual is a good idea when a function does not work like you expect it to.