Even though i'm working with php from a long time now this issue is making me really confused. Let me explain whats going on, Suppose i'm booking an appointment for a Client at: 2019-03-31 10:00:00
and the appointment is going to be of 15 minutes so what i do is i do add these 15 minutes to the starting time of appointment which is 10:00:00
, so that will turn up to be: 10:15:00
ending time of appointment, now what is happening is "ONLY" with date: 2019-03-31
(31st only)
the date functionality is adding an additional hour to the time it supposed to be so instead of: 10:15:00
it changes to: 11:15:00
, i did check everywhere there is no additional code above this code to change the hour i did add the below exact script main file is using in another file on same server and that just works fine with same date and same timing:
$txtstart_date = '2019-03-31';
$day_time = '10:00';
$hrmin = explode(":",$day_time);
$hours = '0';
$minut = '15';
$selected_date_time = new DateTime($txtstart_date.' '.$day_time.':00');
$selected_date_time = $selected_date_time->format('Y-m-d H:i:s');
$selected_hours = new DateTime($selected_date_time);
if($hours){
$selected_hours = $selected_hours->modify('+'.$hours.' hours');
}
if($minut){
$selected_hours = $selected_hours->modify('+'.$minut.' minutes');
}
$selected_hours = $selected_hours->format('Y-m-d H:i:s');
echo date('Y-m-d H:i:s',strtotime($selected_hours));
it would be really great if anyone could clear the doubt here.