UTC TO UTC+3 time issues

Hello All,

I am experiencing a wierd sittuation here.

I am calling an API and from the response i get a UTC Time and convert it to UTC+3.

Sometimes it works and sometimes it doesn’t convert.
Part of the code:

if(mysqli_num_rows($res) == 0) {
  $I_ID = $response->down_services_list[$i]->incident_id;
  $SID = $response->down_services_list[$i]->service_id;
  $Land = $response->down_services_list[$i]->landscape_name;
  $Time = $response->down_services_list[$i]->start_of_outage_utc; 
  $timestamp = strtotime($Time)+3*60*60; 
  $Time = date('Y-m-d H:i:m', $timestamp);
  $State = $response->down_services_list[$i]->service_state." / ".$response->down_services_list[$i]->service_status;
  $sql = "INSERT INTO HaaS_Down.Down (Incident_ID,ServiceID,Landscape,Timestamp_Down,State,Acknowledge) VALUES ('$I_ID','$SID', '$Land', '$Time','$State','0')";
 mysqli_query($conn,$sql);
}

I am sure that the API’s response is aways correct and aways in UTC time. However there are some times that the “time-adding-part” doesn’t work.

Any suggestions?

function AddThreeToUtcTime($date) {
	$utcPlusThree = DateTime::createFromFormat('Y-m-d H:i:s', $date);
	$utcPlusThree = $utcPlusThree->modify('+3 hours');
	return $utcPlusThree->format('Y-m-d H:i:s');
}

$date = '2019-08-09 11:25:00';	
echo AddThreeToUtcTime($date);
1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service